[SCCP] Use range info to prove AddInst has NUW flag.
authorFlorian Hahn <flo@fhahn.com>
Tue, 24 Jan 2023 20:53:06 +0000 (20:53 +0000)
committerFlorian Hahn <flo@fhahn.com>
Tue, 24 Jan 2023 20:53:07 +0000 (20:53 +0000)
commitde122cb920080fd9e24b2777114271fbef932d5e
treebf3d1cd359aa180e590e25dba4f0d8cf9b973549
parent0bb7be5ff61e910addc5d8a7887f54d78a2d43ae
[SCCP] Use range info to prove AddInst has NUW flag.

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

Follow-ups will include adding NSW and extension to more
OverflowingBinaryOperators.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D142387
14 files changed:
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