Skip to content

Commit

Permalink
[SelectionDAG] Handle vscale range wrapping in isKnownNeverZero
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lukel97 committed Jul 9, 2024
1 parent 7346e7c commit baf22a5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit baf22a5

Please sign in to comment.