[llvm-commits] [llvm] r149315 - /llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Eli Friedman eli.friedman at gmail.com
Mon Jan 30 17:08:03 PST 2012


Author: efriedma
Date: Mon Jan 30 19:08:03 2012
New Revision: 149315

URL: http://llvm.org/viewvc/llvm-project?rev=149315&view=rev
Log:
Use the correct ShiftAmtTy for creating shifts after legalization.  PR11881.  Not committing a testcase because I think it will be too fragile.


Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=149315&r1=149314&r2=149315&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Mon Jan 30 19:08:03 2012
@@ -1612,15 +1612,17 @@
 
     APInt MsbMask = APInt::getHighBitsSet(BitWidth, 1);
     // If we only care about the highest bit, don't bother shifting right.
-    if (MsbMask ==  DemandedMask) {
+    if (MsbMask == DemandedMask) {
       unsigned ShAmt = ExVT.getScalarType().getSizeInBits();
       SDValue InOp = Op.getOperand(0);
-      // In this code we may handle vector types. We can't use the
-      // getShiftAmountTy API because it only works on scalars.
-      // We use the shift value type because we know that its an integer
-      // with enough bits.
-      SDValue ShiftAmt = TLO.DAG.getConstant(BitWidth - ShAmt,
-                                             Op.getValueType());
+
+      // Compute the correct shift amount type, which must be getShiftAmountTy
+      // for scalar types after legalization.
+      EVT ShiftAmtTy = Op.getValueType();
+      if (TLO.LegalTypes() && !ShiftAmtTy.isVector())
+        ShiftAmtTy = getShiftAmountTy(ShiftAmtTy);
+
+      SDValue ShiftAmt = TLO.DAG.getConstant(BitWidth - ShAmt, ShiftAmtTy);
       return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::SHL, dl,
                                             Op.getValueType(), InOp, ShiftAmt));
     }





More information about the llvm-commits mailing list