[PATCH] D142387: [SCCP] Use range info to prove AddInst has NUW flag.
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 24 13:17:27 PST 2023
nikic added inline comments.
================
Comment at: llvm/lib/Transforms/Utils/SCCPSolver.cpp:191
+ auto RangeB = GetRange(Inst.getOperand(1));
+ auto NUWRange = ConstantRange::makeGuaranteedNoWrapRegion(
+ Instruction::Add, RangeB, OverflowingBinaryOperator::NoUnsignedWrap);
----------------
fhahn wrote:
> nikic wrote:
> > This should be guarded under `if (!Inst.hasNoUnsignedWrap())`. Otherwise we will report an unnecessary change.
> Thanks, changed to `if (!Inst.hasNoUnsignedWrap() &&NUWRange.contains(RangeA))`. Could also have a separate check guarding `makeGuaranteedNoWrapRegion`, which would increase nesting though and hopefully existing compilers should be smart enough to delay the computation :)
>
Existing compilers almost certainly can't delay that computation (it's not LLVM_READONLY, and I'm not sure clang would sink the call even then).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142387/new/
https://reviews.llvm.org/D142387
More information about the llvm-commits
mailing list