]> granicus.if.org Git - llvm/commitdiff
[X86] Convert to Constant arguments to MMX shift by i32 intrinsics to TargetConstant...
authorCraig Topper <craig.topper@intel.com>
Mon, 23 Sep 2019 01:21:51 +0000 (01:21 +0000)
committerCraig Topper <craig.topper@intel.com>
Mon, 23 Sep 2019 01:21:51 +0000 (01:21 +0000)
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
lib/Target/X86/X86InstrMMX.td

index b666be73e40eba823f235d1ebc2b682d626a96a6..2e40d8805f329f08eec624bd22168111a9de167d 100644 (file)
@@ -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<ConstantSDNode>(ShAmt))
-      return Op;
+    // If the argument is a constant, convert it to a target constant.
+    if (auto *C = dyn_cast<ConstantSDNode>(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),
index ed445529914a24c5d7c8979ce11f5861b989464b..cd9a866c91cbb2cb1177e0585dee3930bcf31ccd 100644 (file)
@@ -66,7 +66,7 @@ let Constraints = "$src1 = $dst" in {
     def ri : MMXIi8<opc2, ImmForm, (outs VR64:$dst),
                                    (ins VR64:$src1, i32u8imm:$src2),
                     !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
-           [(set VR64:$dst, (IntId2 VR64:$src1, imm:$src2))]>,
+           [(set VR64:$dst, (IntId2 VR64:$src1, timm:$src2))]>,
            Sched<[schedImm]>;
   }
 }