[llvm] [SimplifyCFG] handle monotonic wrapped case for D150943 (PR #65882)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 11 19:44:41 PDT 2023
================
@@ -6082,15 +6083,20 @@ SwitchLookupTable::SwitchLookupTable(
LinearMappingPossible = false;
break;
}
- Wrapped |=
- Dist.isStrictlyPositive() ? Val.sle(PrevVal) : Val.sgt(PrevVal);
+ NMon |= Dist.isStrictlyPositive() ? Val.sle(PrevVal) : Val.sgt(PrevVal);
}
PrevVal = Val;
}
if (LinearMappingPossible) {
LinearOffset = cast<ConstantInt>(TableContents[0]);
LinearMultiplier = ConstantInt::get(M.getContext(), DistToPrev);
- LinearMapValWrapped = Wrapped;
+ bool MayMWrap = false, MayOWrap = false;
+ APInt M = LinearMultiplier->getValue(), O = LinearOffset->getValue();
+ APInt Res = O.sadd_ov(
+ M.smul_ov(APInt(M.getBitWidth(), TableSize - 1), MayMWrap), MayOWrap);
+ // To avoid -Wunused-result.
+ (void)Res;
----------------
nikic wrote:
You can directly use `(void)` on the return value, no need to store it into an unused variable.
https://github.com/llvm/llvm-project/pull/65882
More information about the llvm-commits
mailing list