[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

Reid Spencer reid at x10sys.com
Sat Dec 23 16:41:14 PST 2006



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.575 -> 1.576
---
Log message:

For PR1066: http://llvm.org/PR1066 :
Fix this by ensuring that a bitcast is inserted to do sign switching. This
is only temporarily needed as the merging of signed and unsigned is next
on the SignlessTypes plate.


---
Diffs of the changes:  (+8 -2)

 InstructionCombining.cpp |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.575 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.576
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.575	Sat Dec 23 13:17:57 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Sat Dec 23 18:40:59 2006
@@ -2002,8 +2002,14 @@
             if (CU->getZExtValue() == 
                 SI->getType()->getPrimitiveSizeInBits()-1) {
               // Ok, the transformation is safe.  Insert AShr.
-              return new ShiftInst(Instruction::AShr, SI->getOperand(0),
-                                    CU, SI->getName());
+              // FIXME: Once integer types are signless, this cast should be 
+              // removed.  
+              Value *ShiftOp = SI->getOperand(0); 
+              if (ShiftOp->getType() != I.getType()) 
+                ShiftOp = InsertCastBefore(Instruction::BitCast, ShiftOp, 
+                                           I.getType(), I); 
+              return new ShiftInst(Instruction::AShr, ShiftOp, CU,
+                                   SI->getName());
             }
           }
         }






More information about the llvm-commits mailing list