[llvm] [indvars] Support known positive extends in getExtendedOperandRecurrence (PR #70990)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 3 08:55:55 PDT 2023
================
@@ -1384,7 +1384,22 @@ WidenIV::getExtendedOperandRecurrence(WidenIV::NarrowIVDefUse DU) {
else if (ExtKind == ExtendKind::Zero && OBO->hasNoUnsignedWrap())
ExtendOperExpr = SE->getZeroExtendExpr(
SE->getSCEV(DU.NarrowUse->getOperand(ExtendOperIdx)), WideType);
- else
+ else if (DU.NeverNegative) {
----------------
nikic wrote:
I would write the code here like this, to avoid duplicating the logic:
```
if (OBO->hasNoSignedWrap() && (ExtKind == ExtendKind::Sign || DU.NeverNegative)) {
ExtKind = ExtendKind::Sign;
ExtendOperExpr = SE->getSignExtendExpr(
SE->getSCEV(DU.NarrowUse->getOperand(ExtendOperIdx)), WideType);
} else if (OBO->hasNoUnsignedWrap() && (ExtKind == ExtendKind::Zero || DU.NeverNegative)) {
ExtKind = ExtendKind::Zero;
ExtendOperExpr = SE->getZeroExtendExpr(
SE->getSCEV(DU.NarrowUse->getOperand(ExtendOperIdx)), WideType);
} else
return {nullptr, ExtendKind::Unknown};
```
https://github.com/llvm/llvm-project/pull/70990
More information about the llvm-commits
mailing list