From 0c5b3f0761296c4afda969cf7f72b770f8ff59fb Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Thu, 10 Nov 2016 14:35:09 +0000 Subject: [PATCH] [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<(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<isOpaque()) diff --git a/test/CodeGen/X86/combine-shl.ll b/test/CodeGen/X86/combine-shl.ll index a35a30927a8..68c4ddffdf3 100644 --- a/test/CodeGen/X86/combine-shl.ll +++ b/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, %2 = shl <4 x i32> %1, -- 2.40.0