Skip to content

[InstCombine] Infer exact for lshr by cttz #136696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 29, 2025
12 changes: 12 additions & 0 deletions llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,18 @@ static bool setShiftFlags(BinaryOperator &I, const SimplifyQuery &Q) {
I.setIsExact();
return true;
}
//Fix #131444
if (auto *Cttz = dyn_cast<IntrinsicInst>(I.getOperand(1))) {
if (Cttz->getIntrinsicID() == Intrinsic::cttz &&
Cttz->getOperand(0) == I.getOperand(0)) {
if (auto *Const = dyn_cast<ConstantInt>(Cttz->getOperand(1))) {
if (Const->isOne()) {
I.setIsExact();
return true;
}
}
}
}
}

// Compute what we know about shift count.
Expand Down
Loading