[PATCH] D142390: [SCCP] Use range info to prove AddInst has NSW flag.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 23 10:49:10 PST 2023


fhahn created this revision.
fhahn added reviewers: nikic, spatel, efriedma.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
fhahn requested review of this revision.
Herald added a project: LLVM.

This patch updates SCCP to use the value ranges of AddInst operands to
try to prove the AddInst does not overflow in the signed sense and
adds the NSW flag. The reasoning is done with
makeGuaranteedNoWrapRegion (thanks @nikic for point it out!).

Follow-ups will include extending this to more
OverflowingBinaryOperators.

Depends on D142387 <https://reviews.llvm.org/D142387>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142390

Files:
  llvm/lib/Transforms/Utils/SCCPSolver.cpp
  llvm/test/Transforms/SCCP/add-nuw-nsw-flags.ll
  llvm/test/Transforms/SCCP/binaryops-constexprs.ll
  llvm/test/Transforms/SCCP/conditions-ranges-with-undef.ll
  llvm/test/Transforms/SCCP/conditions-ranges.ll
  llvm/test/Transforms/SCCP/ip-add-range-to-call.ll
  llvm/test/Transforms/SCCP/ip-constant-ranges.ll
  llvm/test/Transforms/SCCP/ip-ranges-binaryops.ll
  llvm/test/Transforms/SCCP/ip-ranges-casts.ll
  llvm/test/Transforms/SCCP/ip-ranges-phis.ll
  llvm/test/Transforms/SCCP/ip-ranges-select.ll
  llvm/test/Transforms/SCCP/return-argument.ll
  llvm/test/Transforms/SCCP/return-constants.ll
  llvm/test/Transforms/SCCP/widening.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142390.491455.patch
Type: text/x-patch
Size: 20793 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230123/8960d81a/attachment.bin>


More information about the llvm-commits mailing list