On Oct 25, 2006, at 12:15 PM, Reid Spencer wrote:

Attached are two patch files to replace the DIV instruction with 3
instructions: SDiv, UDiv, FDiv. The first file patches llvm. The second
file patches llvm-gcc4. 

This is the 2nd attempt to provide the patch.  All comments are welcome.

llvm-gcc part first:

Instead of adding a switch stmt to EmitBinOp, please change it to something like this:

+++ gcc/llvm-convert.cpp (working copy)
@@ -544,9 +544,15 @@
   case PLUS_EXPR:      Result = EmitBinOp(exp, DestLoc, Instruction::Add);break;
   case MINUS_EXPR:     Result = EmitBinOp(exp, DestLoc, Instruction::Sub);break;
   case MULT_EXPR:      Result = EmitBinOp(exp, DestLoc, Instruction::Mul);break;
-  case TRUNC_DIV_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Div);break;
-  case EXACT_DIV_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Div);break;
-  case RDIV_EXPR:      Result = EmitBinOp(exp, DestLoc, Instruction::Div);break;
+  case TRUNC_DIV_EXPR: 
+    if (TREE_UNSIGNED(TREE_TYPE(exp)))
+      Result = EmitBinOp(exp, DestLoc, Instruction::UDiv);
+    else
+      Result = EmitBinOp(exp, DestLoc, Instruction::SDiv);
+    break;

EXACT_DIV_EXPR should always be UDiv, RDIV_EXPR is fine.

-Chris


_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to