From cd20c6fb18230f399fc99276fbdee14ce9faf6a1 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 23 Jul 2010 21:08:12 +0000 Subject: [PATCH] Use the proper type for shift counts. This fixes a bootstrap error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109265 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/TargetLowering.cpp | 5 ++++- test/CodeGen/X86/shl-anyext.ll | 22 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 389f2ea5ff1..12185a3d4c3 100644 --- a/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -1380,9 +1380,12 @@ bool TargetLowering::SimplifyDemandedBits(SDValue Op, 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(), diff --git a/test/CodeGen/X86/shl-anyext.ll b/test/CodeGen/X86/shl-anyext.ll index 6dc95317d14..10d489b9a8a 100644 --- a/test/CodeGen/X86/shl-anyext.ll +++ b/test/CodeGen/X86/shl-anyext.ll @@ -16,3 +16,25 @@ if.end523: ; preds = %if.end453 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 ; [#uses=1] + br label %bb1 + +bb1: ; preds = %bb + %tmp2 = zext i32 %tmp to i64 ; [#uses=2] + %tmp3 = add i64 %tmp2, 1 ; [#uses=1] + %tmp4 = xor i64 %tmp2, 536870911 ; [#uses=1] + %tmp5 = and i64 %tmp3, %tmp4 ; [#uses=1] + %tmp6 = shl i64 %tmp5, 3 ; [#uses=1] + %tmp7 = sub i64 64, %tmp6 ; [#uses=1] + %tmp8 = and i64 %tmp7, 4294967288 ; [#uses=1] + %tmp9 = lshr i64 -1, %tmp8 ; [#uses=1] + call void @bar(i64 %tmp9) + ret void +} -- 2.34.1