[llvm] r174327 - X86: Open up some opportunities for constant folding by postponing shift lowering.
Benjamin Kramer
benny.kra at googlemail.com
Mon Feb 4 07:19:33 PST 2013
Author: d0k
Date: Mon Feb 4 09:19:33 2013
New Revision: 174327
URL: http://llvm.org/viewvc/llvm-project?rev=174327&view=rev
Log:
X86: Open up some opportunities for constant folding by postponing shift lowering.
Fixes PR15141.
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/CodeGen/X86/avx-shift.ll
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=174327&r1=174326&r2=174327&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Feb 4 09:19:33 2013
@@ -11583,8 +11583,7 @@ SDValue X86TargetLowering::LowerShift(SD
// Lower SHL with variable shift amount.
if (VT == MVT::v4i32 && Op->getOpcode() == ISD::SHL) {
- Op = DAG.getNode(X86ISD::VSHLI, dl, VT, Op.getOperand(1),
- DAG.getConstant(23, MVT::i32));
+ Op = DAG.getNode(ISD::SHL, dl, VT, Amt, DAG.getConstant(23, VT));
Op = DAG.getNode(ISD::ADD, dl, VT, Op, DAG.getConstant(0x3f800000U, VT));
Op = DAG.getNode(ISD::BITCAST, dl, MVT::v4f32, Op);
@@ -11595,8 +11594,7 @@ SDValue X86TargetLowering::LowerShift(SD
assert(Subtarget->hasSSE2() && "Need SSE2 for pslli/pcmpeq.");
// a = a << 5;
- Op = DAG.getNode(X86ISD::VSHLI, dl, MVT::v8i16, Op.getOperand(1),
- DAG.getConstant(5, MVT::i32));
+ Op = DAG.getNode(ISD::SHL, dl, VT, Amt, DAG.getConstant(5, VT));
Op = DAG.getNode(ISD::BITCAST, dl, VT, Op);
// Turn 'a' into a mask suitable for VSELECT
Modified: llvm/trunk/test/CodeGen/X86/avx-shift.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avx-shift.ll?rev=174327&r1=174326&r2=174327&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/avx-shift.ll (original)
+++ llvm/trunk/test/CodeGen/X86/avx-shift.ll Mon Feb 4 09:19:33 2013
@@ -112,6 +112,16 @@ define <8 x i32> @vshift08(<8 x i32> %a)
ret <8 x i32> %bitop
}
+; PR15141
+; CHECK: _vshift13:
+; CHECK-NOT: vpsll
+; CHECK: vcvttps2dq
+; CHECK-NEXT: vpmulld
+define <4 x i32> @vshift13(<4 x i32> %in) {
+ %T = shl <4 x i32> %in, <i32 0, i32 1, i32 2, i32 4>
+ ret <4 x i32> %T
+}
+
;;; Uses shifts for sign extension
; CHECK: _sext_v16i16
; CHECK: vpsllw
More information about the llvm-commits
mailing list