diff options
| author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2016-11-10 14:35:09 +0000 |
|---|---|---|
| committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2016-11-10 14:35:09 +0000 |
| commit | 37c9034bd6d9ac397450e19314f875823e1b6819 (patch) | |
| tree | e20695f11b1419dc57126fd17834bb680afb5cd2 /llvm | |
| parent | c16824d2173cf1e24c6b6e771186f7c9335e1480 (diff) | |
| download | bcm5719-llvm-37c9034bd6d9ac397450e19314f875823e1b6819.tar.gz bcm5719-llvm-37c9034bd6d9ac397450e19314f875823e1b6819.zip | |
[DAGCombiner] Correctly extract the ConstOrConstSplat shift value for SHL nodes
We were failing to extract a constant splat shift value if the shifted value was being masked.
The (shl (and (setcc) N01CV) N1CV) -> (and (setcc) N01CV<<N1CV) combine was unnecessarily preventing this.
llvm-svn: 286454
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 5 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/combine-shl.ll | 2 |
2 files changed, 2 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index b3c493baba9..3d5f81ed215 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -4512,7 +4512,6 @@ SDValue DAGCombiner::visitSHL(SDNode *N) { unsigned OpSizeInBits = VT.getScalarSizeInBits(); // fold vector ops - ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N1); if (VT.isVector()) { if (SDValue FoldedVOp = SimplifyVBinOp(N)) return FoldedVOp; @@ -4533,12 +4532,12 @@ SDValue DAGCombiner::visitSHL(SDNode *N) { N01CV, N1CV)) return DAG.getNode(ISD::AND, SDLoc(N), VT, N00, C); } - } else { - N1C = isConstOrConstSplat(N1); } } } + ConstantSDNode *N1C = isConstOrConstSplat(N1); + // fold (shl c1, c2) -> c1<<c2 ConstantSDNode *N0C = getAsNonOpaqueConstant(N0); if (N0C && N1C && !N1C->isOpaque()) diff --git a/llvm/test/CodeGen/X86/combine-shl.ll b/llvm/test/CodeGen/X86/combine-shl.ll index a35a30927a8..68c4ddffdf3 100644 --- a/llvm/test/CodeGen/X86/combine-shl.ll +++ b/llvm/test/CodeGen/X86/combine-shl.ll @@ -47,12 +47,10 @@ define <4 x i32> @combine_vec_shl_outofrange1(<4 x i32> %x) { define <4 x i32> @combine_vec_shl_outofrange2(<4 x i32> %a0) { ; SSE-LABEL: combine_vec_shl_outofrange2: ; SSE: # BB#0: -; SSE-NEXT: xorps %xmm0, %xmm0 ; SSE-NEXT: retq ; ; AVX-LABEL: combine_vec_shl_outofrange2: ; AVX: # BB#0: -; AVX-NEXT: vxorps %xmm0, %xmm0, %xmm0 ; AVX-NEXT: retq %1 = and <4 x i32> %a0, <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647> %2 = shl <4 x i32> %1, <i32 33, i32 33, i32 33, i32 33> |

