From 1cc01c3228485e4ed6be2b6d10b1061f6a58ae36 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Mon, 25 Mar 2019 06:53:45 +0000 Subject: [PATCH] [X86] When selecting (x << C1) op C2 as (x op (C2>>C1)) << C1, use the operation VT for the target constant. 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. llvm-svn: 356869 --- llvm/lib/Target/X86/X86ISelDAGToDAG.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp index bfa0df7..6290a8f 100644 --- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -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), -- 2.7.4