[llvm-branch-commits] [llvm-branch] r109305 - in /llvm/branches/Apple/williamson: lib/CodeGen/SelectionDAG/TargetLowering.cpp lib/CodeGen/SelectionDAG/TargetLowering.cpp.orig test/CodeGen/X86/shl-anyext.ll
Daniel Dunbar
daniel at zuster.org
Fri Jul 23 18:01:59 PDT 2010
Author: ddunbar
Date: Fri Jul 23 20:01:59 2010
New Revision: 109305
URL: http://llvm.org/viewvc/llvm-project?rev=109305&view=rev
Log:
Merge r109265:
--
Author: Dan Gohman <gohman at apple.com>
Date: Fri Jul 23 21:08:12 2010 +0000
Use the proper type for shift counts. This fixes a bootstrap error.
Modified:
llvm/branches/Apple/williamson/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/branches/Apple/williamson/lib/CodeGen/SelectionDAG/TargetLowering.cpp.orig
llvm/branches/Apple/williamson/test/CodeGen/X86/shl-anyext.ll
Modified: llvm/branches/Apple/williamson/lib/CodeGen/SelectionDAG/TargetLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/williamson/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=109305&r1=109304&r2=109305&view=diff
==============================================================================
--- llvm/branches/Apple/williamson/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original)
+++ llvm/branches/Apple/williamson/lib/CodeGen/SelectionDAG/TargetLowering.cpp Fri Jul 23 20:01:59 2010
@@ -1374,9 +1374,12 @@
BitWidth - InnerVT.getSizeInBits()) &
DemandedMask) == 0 &&
isTypeDesirableForOp(ISD::SHL, InnerVT)) {
+ EVT ShTy = getShiftAmountTy();
+ if (!APInt(BitWidth, ShAmt).isIntN(ShTy.getSizeInBits()))
+ ShTy = InnerVT;
SDValue NarrowShl =
TLO.DAG.getNode(ISD::SHL, dl, InnerVT, InnerOp,
- TLO.DAG.getConstant(ShAmt, InnerVT));
+ TLO.DAG.getConstant(ShAmt, ShTy));
return
TLO.CombineTo(Op,
TLO.DAG.getNode(ISD::ANY_EXTEND, dl, Op.getValueType(),
Modified: llvm/branches/Apple/williamson/lib/CodeGen/SelectionDAG/TargetLowering.cpp.orig
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/williamson/lib/CodeGen/SelectionDAG/TargetLowering.cpp.orig?rev=109305&r1=109304&r2=109305&view=diff
==============================================================================
--- llvm/branches/Apple/williamson/lib/CodeGen/SelectionDAG/TargetLowering.cpp.orig (original)
+++ llvm/branches/Apple/williamson/lib/CodeGen/SelectionDAG/TargetLowering.cpp.orig Fri Jul 23 20:01:59 2010
@@ -1361,9 +1361,29 @@
}
}
- if (SimplifyDemandedBits(Op.getOperand(0), NewMask.lshr(ShAmt),
+ if (SimplifyDemandedBits(InOp, NewMask.lshr(ShAmt),
KnownZero, KnownOne, TLO, Depth+1))
return true;
+
+ // Convert (shl (anyext x, c)) to (anyext (shl x, c)) if the high bits
+ // are not demanded. This will likely allow the anyext to be folded away.
+ if (InOp.getNode()->getOpcode() == ISD::ANY_EXTEND) {
+ SDValue InnerOp = InOp.getNode()->getOperand(0);
+ EVT InnerVT = InnerOp.getValueType();
+ if ((APInt::getHighBitsSet(BitWidth,
+ BitWidth - InnerVT.getSizeInBits()) &
+ DemandedMask) == 0 &&
+ isTypeDesirableForOp(ISD::SHL, InnerVT)) {
+ SDValue NarrowShl =
+ TLO.DAG.getNode(ISD::SHL, dl, InnerVT, InnerOp,
+ TLO.DAG.getConstant(ShAmt, InnerVT));
+ return
+ TLO.CombineTo(Op,
+ TLO.DAG.getNode(ISD::ANY_EXTEND, dl, Op.getValueType(),
+ NarrowShl));
+ }
+ }
+
KnownZero <<= SA->getZExtValue();
KnownOne <<= SA->getZExtValue();
// low bits known zero.
Modified: llvm/branches/Apple/williamson/test/CodeGen/X86/shl-anyext.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/williamson/test/CodeGen/X86/shl-anyext.ll?rev=109305&r1=109304&r2=109305&view=diff
==============================================================================
--- llvm/branches/Apple/williamson/test/CodeGen/X86/shl-anyext.ll (original)
+++ llvm/branches/Apple/williamson/test/CodeGen/X86/shl-anyext.ll Fri Jul 23 20:01:59 2010
@@ -16,3 +16,25 @@
store i32 %conv820, i32* %p
ret void
}
+
+; CHECK: foo:
+
+declare void @bar(i64)
+
+define fastcc void @foo(i32 %t) {
+bb:
+ %tmp = add i32 %t, -1 ; <i32> [#uses=1]
+ br label %bb1
+
+bb1: ; preds = %bb
+ %tmp2 = zext i32 %tmp to i64 ; <i64> [#uses=2]
+ %tmp3 = add i64 %tmp2, 1 ; <i64> [#uses=1]
+ %tmp4 = xor i64 %tmp2, 536870911 ; <i64> [#uses=1]
+ %tmp5 = and i64 %tmp3, %tmp4 ; <i64> [#uses=1]
+ %tmp6 = shl i64 %tmp5, 3 ; <i64> [#uses=1]
+ %tmp7 = sub i64 64, %tmp6 ; <i64> [#uses=1]
+ %tmp8 = and i64 %tmp7, 4294967288 ; <i64> [#uses=1]
+ %tmp9 = lshr i64 -1, %tmp8 ; <i64> [#uses=1]
+ call void @bar(i64 %tmp9)
+ ret void
+}
More information about the llvm-branch-commits
mailing list