[llvm-commits] CVS: llvm/lib/Target/TargetLowering.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Feb 26 16:36:39 PST 2006
Changes in directory llvm/lib/Target:
TargetLowering.cpp updated: 1.39 -> 1.40
---
Log message:
Check RHS simplification before LHS simplification to avoid infinitely looping
on PowerPC/small-arguments.ll
---
Diffs of the changes: (+17 -18)
TargetLowering.cpp | 35 +++++++++++++++++------------------
1 files changed, 17 insertions(+), 18 deletions(-)
Index: llvm/lib/Target/TargetLowering.cpp
diff -u llvm/lib/Target/TargetLowering.cpp:1.39 llvm/lib/Target/TargetLowering.cpp:1.40
--- llvm/lib/Target/TargetLowering.cpp:1.39 Sun Feb 26 18:22:28 2006
+++ llvm/lib/Target/TargetLowering.cpp Sun Feb 26 18:36:27 2006
@@ -201,7 +201,23 @@
KnownZero = ~KnownOne & DemandedMask;
return false; // Don't fall through, will infinitely loop.
case ISD::AND:
- // If either the LHS or the RHS are Zero, the result is zero.
+ // If the RHS is a constant, check to see if the LHS would be zero without
+ // using the bits from the RHS. Below, we use knowledge about the RHS to
+ // simplify the LHS, here we're using information from the LHS to simplify
+ // the RHS.
+ if (ConstantSDNode *RHSC = dyn_cast<ConstantSDNode>(Op.getOperand(1))) {
+ uint64_t LHSZero, LHSOne;
+ ComputeMaskedBits(Op.getOperand(0), DemandedMask,
+ LHSZero, LHSOne, Depth+1);
+ // If the LHS already has zeros where RHSC does, this and is dead.
+ if ((LHSZero & DemandedMask) == (~RHSC->getValue() & DemandedMask))
+ return TLO.CombineTo(Op, Op.getOperand(0));
+ // If any of the set bits in the RHS are known zero on the LHS, shrink
+ // the constant.
+ if (TLO.ShrinkDemandedConstant(Op, ~LHSZero & DemandedMask))
+ return true;
+ }
+
if (SimplifyDemandedBits(Op.getOperand(1), DemandedMask, KnownZero,
KnownOne, TLO, Depth+1))
return true;
@@ -224,23 +240,6 @@
if (TLO.ShrinkDemandedConstant(Op, DemandedMask & ~KnownZero2))
return true;
- // If the RHS is a constant, check to see if the LHS would be zero without
- // using the bits from the RHS. Above, we used knowledge about the RHS to
- // simplify the LHS, here we're using information from the LHS to simplify
- // the RHS.
- if (ConstantSDNode *RHSC = dyn_cast<ConstantSDNode>(Op.getOperand(1))) {
- uint64_t LHSZero, LHSOne;
- ComputeMaskedBits(Op.getOperand(0), DemandedMask,
- LHSZero, LHSOne, Depth+1);
- // If the LHS already has zeros where RHSC does, this and is dead.
- if ((LHSZero & DemandedMask) == (~RHSC->getValue() & DemandedMask))
- return TLO.CombineTo(Op, Op.getOperand(0));
- // If any of the set bits in the RHS are known zero on the LHS, shrink
- // the constant.
- if (TLO.ShrinkDemandedConstant(Op, ~LHSZero & DemandedMask))
- return true;
- }
-
// Output known-1 bits are only known if set in both the LHS & RHS.
KnownOne &= KnownOne2;
// Output known-0 are known to be clear if zero in either the LHS | RHS.
More information about the llvm-commits
mailing list