diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index cf42a2200564ba..3eff266bc89d45 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -3082,6 +3082,7 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts, Known = computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1); Known2 = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1); bool SelfMultiply = Op.getOperand(0) == Op.getOperand(1); + // TODO: SelfMultiply can be poison, but not undef. SelfMultiply &= isGuaranteedNotToBeUndefOrPoison( Op.getOperand(0), DemandedElts, false, Depth + 1); Known = KnownBits::mul(Known, Known2, SelfMultiply); diff --git a/llvm/test/CodeGen/X86/combine-mul.ll b/llvm/test/CodeGen/X86/combine-mul.ll index 403443da60ee3a..0d0aff21550a5f 100644 --- a/llvm/test/CodeGen/X86/combine-mul.ll +++ b/llvm/test/CodeGen/X86/combine-mul.ll @@ -393,7 +393,7 @@ define <4 x i32> @combine_mul_self_knownbits_vector(<4 x i32> %x) { ret <4 x i32> %2 } -; mul(x,x) - bit[1] is 0, but if demanding the other bits the source must not be undef/poison +; mul(x,x) - bit[1] is 0, but if demanding the other bits the source must not be undef define i64 @combine_mul_self_demandedbits(i64 %x) { ; SSE-LABEL: combine_mul_self_demandedbits: