[PATCH] D142387: [SCCP] Use range info to prove AddInst has NUW flag.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 24 12:55:25 PST 2023


fhahn marked an inline comment as done.
fhahn 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);
----------------
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 :)



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