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

Chris Lattner lattner at cs.uiuc.edu
Mon Feb 13 14:41:19 PST 2006



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.433 -> 1.434
---
Log message:

If any of the sign extended bits are demanded, the input sign bit is demanded
for a sign extension.

This fixes InstCombine/2006-02-13-DemandedMiscompile.ll and Ptrdist/bc.



---
Diffs of the changes:  (+9 -3)

 InstructionCombining.cpp |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.433 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.434
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.433	Mon Feb 13 00:09:08 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Mon Feb 13 16:41:07 2006
@@ -889,15 +889,21 @@
       KnownZero |= NewBits;
     } else {
       // Sign extension.
-      if (SimplifyDemandedBits(I->getOperand(0),
-                               DemandedMask & SrcTy->getIntegralTypeMask(),
+      uint64_t InSignBit = 1ULL << (SrcTy->getPrimitiveSizeInBits()-1);
+      int64_t InputDemandedBits = DemandedMask & SrcTy->getIntegralTypeMask();
+
+      // If any of the sign extended bits are demanded, we know that the sign
+      // bit is demanded.
+      if (NewBits & DemandedMask)
+        InputDemandedBits |= InSignBit;
+      
+      if (SimplifyDemandedBits(I->getOperand(0), InputDemandedBits,
                                KnownZero, KnownOne, Depth+1))
         return true;
       assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); 
       
       // If the sign bit of the input is known set or clear, then we know the
       // top bits of the result.
-      uint64_t InSignBit = 1ULL << (SrcTy->getPrimitiveSizeInBits()-1);
 
       // If the input sign bit is known zero, or if the NewBits are not demanded
       // convert this into a zero extension.






More information about the llvm-commits mailing list