[llvm] baf22a5 - [SelectionDAG] Handle vscale range wrapping in isKnownNeverZero
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 9 08:05:45 PDT 2024
Author: Luke Lau
Date: 2024-07-09T23:05:22+08:00
New Revision: baf22a527ca6571cdf5cd57c524a1fc261207947
URL: https://github.com/llvm/llvm-project/commit/baf22a527ca6571cdf5cd57c524a1fc261207947
DIFF: https://github.com/llvm/llvm-project/commit/baf22a527ca6571cdf5cd57c524a1fc261207947.diff
LOG: [SelectionDAG] Handle vscale range wrapping in isKnownNeverZero
As pointed out by @preames, ConstantRange can wrap so it's possible
for zero to be in a range without zero being the minimum. This fixes
this by checking contains instead.
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 943d2ddc64246..79f90bae1d8d6 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5649,7 +5649,7 @@ bool SelectionDAG::isKnownNeverZero(SDValue Op, unsigned Depth) const {
const APInt &Multiplier = Op.getConstantOperandAPInt(0);
ConstantRange CR =
getVScaleRange(&F, Op.getScalarValueSizeInBits()).multiply(Multiplier);
- if (!CR.getUnsignedMin().isZero())
+ if (!CR.contains(APInt(CR.getBitWidth(), 0)))
return true;
break;
}
More information about the llvm-commits
mailing list