From 72f361078143e37720a4d8c4da9ad89f522044f9 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Mon, 23 Sep 2019 01:21:51 +0000 Subject: [PATCH] [X86] Convert to Constant arguments to MMX shift by i32 intrinsics to TargetConstant during lowering. This allows us to use timm in the isel table which is more consistent with other intrinsics that take an immediate now. We can't declare the intrinsic as taking an ImmArg because we need to match non-constants to the shift by MMX register instruction which we do by mutating the intrinsic id during lowering. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372537 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86ISelLowering.cpp | 11 +++++++---- lib/Target/X86/X86InstrMMX.td | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index b666be73e40..2e40d8805f3 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -23746,10 +23746,14 @@ SDValue X86TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, case Intrinsic::x86_mmx_psrli_q: case Intrinsic::x86_mmx_psrai_w: case Intrinsic::x86_mmx_psrai_d: { + SDLoc DL(Op); SDValue ShAmt = Op.getOperand(2); - // If the argument is a constant, this is fine. - if (isa(ShAmt)) - return Op; + // If the argument is a constant, convert it to a target constant. + if (auto *C = dyn_cast(ShAmt)) { + ShAmt = DAG.getTargetConstant(C->getZExtValue(), DL, MVT::i32); + return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, DL, Op.getValueType(), + Op.getOperand(0), Op.getOperand(1), ShAmt); + } unsigned NewIntrinsic; switch (IntNo) { @@ -23783,7 +23787,6 @@ SDValue X86TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, // The vector shift intrinsics with scalars uses 32b shift amounts but // the sse2/mmx shift instructions reads 64 bits. Copy the 32 bits to an // MMX register. - SDLoc DL(Op); ShAmt = DAG.getNode(X86ISD::MMX_MOVW2D, DL, MVT::x86mmx, ShAmt); return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, DL, Op.getValueType(), DAG.getConstant(NewIntrinsic, DL, MVT::i32), diff --git a/lib/Target/X86/X86InstrMMX.td b/lib/Target/X86/X86InstrMMX.td index ed445529914..cd9a866c91c 100644 --- a/lib/Target/X86/X86InstrMMX.td +++ b/lib/Target/X86/X86InstrMMX.td @@ -66,7 +66,7 @@ let Constraints = "$src1 = $dst" in { def ri : MMXIi8, + [(set VR64:$dst, (IntId2 VR64:$src1, timm:$src2))]>, Sched<[schedImm]>; } } -- 2.50.1