[llvm-commits] llvm-gcc: sign matters for EXACT_DIV_EXPR

Duncan Sands baldrick at free.fr
Mon Jan 15 09:09:20 PST 2007


EXACT_DIV_EXPR can be used on signed operands, so it is wrong to always
turn it into UDiv.  Since EXACT_DIV_EXPR always gives the same result as
TRUNC_DIV_EXPR (it exists in gcc because it might give that result faster
on some targets, not because it gives a different result), it is pointless
to distinguish between the two in LLVM.

Index: gcc/llvm-convert.cpp
===================================================================
--- gcc/llvm-convert.cpp	(revision 248)
+++ gcc/llvm-convert.cpp	(working copy)
@@ -591,14 +591,12 @@
   case MINUS_EXPR:Result = EmitBinOp(exp, DestLoc, Instruction::Sub);break;
   case MULT_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Mul);break;
   case TRUNC_DIV_EXPR: 
+  case EXACT_DIV_EXPR: 
     if (TYPE_UNSIGNED(TREE_TYPE(exp)))
       Result = EmitBinOp(exp, DestLoc, Instruction::UDiv);
     else 
       Result = EmitBinOp(exp, DestLoc, Instruction::SDiv);
     break;
-  case EXACT_DIV_EXPR: 
-    Result = EmitBinOp(exp, DestLoc, Instruction::UDiv);
-    break;
   case RDIV_EXPR:      
     Result = EmitBinOp(exp, DestLoc, Instruction::FDiv);
     break;



More information about the llvm-commits mailing list