]> granicus.if.org Git - llvm/commitdiff
[X86] When selecting (x << C1) op C2 as (x op (C2>>C1)) << C1, use the operation...
authorCraig Topper <craig.topper@intel.com>
Mon, 25 Mar 2019 06:53:45 +0000 (06:53 +0000)
committerCraig Topper <craig.topper@intel.com>
Mon, 25 Mar 2019 06:53:45 +0000 (06:53 +0000)
Normally when the nodes we use here(AND32ri8 for example) are selected their
immediates are just converted from ConstantSDNode to TargetConstantSDNode
without changing VT from the original operation VT. So we should still be
emitting them with the operation VT.

Theoretically this could expose more accurate opportunities for CSE.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356869 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelDAGToDAG.cpp

index bfa0df7db3472eb380c587f0aa08ef05f1814457..6290a8f4a8dcb2a2e0bb4cc4a14e9e09ad7dae34 100644 (file)
@@ -3561,7 +3561,8 @@ void X86DAGToDAGISel::Select(SDNode *Node) {
     }
 
     // Emit the smaller op and the shift.
-    SDValue NewCst = CurDAG->getTargetConstant(Val >> ShlVal, dl, CstVT);
+    // Even though we shrink the constant, the VT should match the operation VT.
+    SDValue NewCst = CurDAG->getTargetConstant(Val >> ShlVal, dl, NVT);
     SDNode *New = CurDAG->getMachineNode(Op, dl, NVT, N0->getOperand(0),NewCst);
     if (ShlVal == 1)
       CurDAG->SelectNodeTo(Node, AddOp, NVT, SDValue(New, 0),