[llvm] [ValueTracking] Take into account whether zero is poison when computing CR for `ct{t,l}z` (PR #122548)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 11 01:04:49 PST 2025
================
@@ -9898,13 +9898,20 @@ static void setLimitsForBinOp(const BinaryOperator &BO, APInt &Lower,
}
}
-static ConstantRange getRangeForIntrinsic(const IntrinsicInst &II) {
+static ConstantRange getRangeForIntrinsic(const IntrinsicInst &II,
+ bool UseInstrInfo) {
unsigned Width = II.getType()->getScalarSizeInBits();
const APInt *C;
switch (II.getIntrinsicID()) {
- case Intrinsic::ctpop:
case Intrinsic::ctlz:
- case Intrinsic::cttz:
+ case Intrinsic::cttz: {
+ APInt Upper = APInt(Width, Width);
+ if (!UseInstrInfo || !match(II.getArgOperand(1), m_One()))
----------------
nikic wrote:
I don't think we normally consider the zero poison flag as part of UseInstrInfo.
Though this does make me wonder whether it may be time to replace this flag with an attribute (i.e. range not including zero on the argument). It would have a higher chance to be dropped, but require less special handling, and automatically enable things like CSE between ctz with different poison flags.
https://github.com/llvm/llvm-project/pull/122548
More information about the llvm-commits
mailing list