diff options
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 12 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/combine-mul.ll | 24 |
2 files changed, 30 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 83e5cc1c92c..1e160c4097f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -3438,13 +3438,13 @@ SDValue DAGCombiner::visitMUL(SDNode *N) { MathOp = ISD::SUB; if (MathOp != ISD::DELETED_NODE) { - unsigned ShAmt = MathOp == ISD::ADD ? (MulC - 1).logBase2() - : (MulC + 1).logBase2(); - assert(ShAmt > 0 && ShAmt < VT.getScalarSizeInBits() && - "Not expecting multiply-by-constant that could have simplified"); + unsigned ShAmt = + MathOp == ISD::ADD ? (MulC - 1).logBase2() : (MulC + 1).logBase2(); + assert(ShAmt < VT.getScalarSizeInBits() && + "multiply-by-constant generated out of bounds shift"); SDLoc DL(N); - SDValue Shl = DAG.getNode(ISD::SHL, DL, VT, N0, - DAG.getConstant(ShAmt, DL, VT)); + SDValue Shl = + DAG.getNode(ISD::SHL, DL, VT, N0, DAG.getConstant(ShAmt, DL, VT)); SDValue R = DAG.getNode(MathOp, DL, VT, Shl, N0); if (ConstValue1.isNegative()) R = DAG.getNode(ISD::SUB, DL, VT, DAG.getConstant(0, DL, VT), R); diff --git a/llvm/test/CodeGen/X86/combine-mul.ll b/llvm/test/CodeGen/X86/combine-mul.ll index f05bbbb885e..8c38352c6b2 100644 --- a/llvm/test/CodeGen/X86/combine-mul.ll +++ b/llvm/test/CodeGen/X86/combine-mul.ll @@ -313,3 +313,27 @@ define <16 x i8> @PR35579(<16 x i8> %x) { ret <16 x i8> %r } +; OSS Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=15429 +define <4 x i64> @fuzz15429(<4 x i64> %InVec) { +; SSE-LABEL: fuzz15429: +; SSE: # %bb.0: +; SSE-NEXT: movdqa %xmm1, %xmm2 +; SSE-NEXT: psllq $3, %xmm2 +; SSE-NEXT: psllq $2, %xmm1 +; SSE-NEXT: pblendw {{.*#+}} xmm1 = xmm1[0,1,2,3],xmm2[4,5,6,7] +; SSE-NEXT: paddq %xmm0, %xmm0 +; SSE-NEXT: movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF +; SSE-NEXT: pinsrq $0, %rax, %xmm0 +; SSE-NEXT: retq +; +; AVX-LABEL: fuzz15429: +; AVX: # %bb.0: +; AVX-NEXT: vpsllvq {{.*}}(%rip), %ymm0, %ymm0 +; AVX-NEXT: movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF +; AVX-NEXT: vpinsrq $0, %rax, %xmm0, %xmm1 +; AVX-NEXT: vpblendd {{.*#+}} ymm0 = ymm1[0,1,2,3],ymm0[4,5,6,7] +; AVX-NEXT: retq + %mul = mul <4 x i64> %InVec, <i64 1, i64 2, i64 4, i64 8> + %I = insertelement <4 x i64> %mul, i64 9223372036854775807, i64 0 + ret <4 x i64> %I +} |

