[llvm] ae9414d - [ValueTracking] Only check for non-undef/poison if already known to be a self-multiply
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 8 07:36:03 PST 2022
Author: Roman Lebedev
Date: 2022-02-08T18:35:29+03:00
New Revision: ae9414d5621f6de5060007ee12c3face233a98c1
URL: https://github.com/llvm/llvm-project/commit/ae9414d5621f6de5060007ee12c3face233a98c1
DIFF: https://github.com/llvm/llvm-project/commit/ae9414d5621f6de5060007ee12c3face233a98c1.diff
LOG: [ValueTracking] Only check for non-undef/poison if already known to be a self-multiply
https://godbolt.org/z/js9fTTG9h
^ we don't care what `isGuaranteedNotToBeUndefOrPoison()` says
unless we already knew that the operands were equal.
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 9fe538df1a87..236db5ef26f8 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -453,8 +453,9 @@ static void computeKnownBitsMul(const Value *Op0, const Value *Op1, bool NSW,
bool SelfMultiply = Op0 == Op1;
// TODO: SelfMultiply can be poison, but not undef.
- SelfMultiply &=
- isGuaranteedNotToBeUndefOrPoison(Op0, Q.AC, Q.CxtI, Q.DT, Depth + 1);
+ if (SelfMultiply)
+ SelfMultiply &=
+ isGuaranteedNotToBeUndefOrPoison(Op0, Q.AC, Q.CxtI, Q.DT, Depth + 1);
Known = KnownBits::mul(Known, Known2, SelfMultiply);
// Only make use of no-wrap flags if we failed to compute the sign bit
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index df09368f6a8a..9693cede668c 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -3083,8 +3083,9 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
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);
+ if (SelfMultiply)
+ SelfMultiply &= isGuaranteedNotToBeUndefOrPoison(
+ Op.getOperand(0), DemandedElts, false, Depth + 1);
Known = KnownBits::mul(Known, Known2, SelfMultiply);
break;
}
More information about the llvm-commits
mailing list