[llvm] d83a96f - [DAG] Make it clear mul(x,x) knownbits bit[1] == 0 check should be for x is undef only
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 1 03:33:41 PST 2022
Author: Simon Pilgrim
Date: 2022-02-01T11:32:14Z
New Revision: d83a96f59f93290aa7771388498bb620974de6b7
URL: https://github.com/llvm/llvm-project/commit/d83a96f59f93290aa7771388498bb620974de6b7
DIFF: https://github.com/llvm/llvm-project/commit/d83a96f59f93290aa7771388498bb620974de6b7.diff
LOG: [DAG] Make it clear mul(x,x) knownbits bit[1] == 0 check should be for x is undef only
As raised on rGffd0e464b4b9, if x is poison, this fold is still ok.
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/test/CodeGen/X86/combine-mul.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index cf42a2200564b..3eff266bc89d4 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 403443da60ee3..0d0aff21550a5 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:
More information about the llvm-commits
mailing list