[PATCH] D59386: [ValueTracking] ConstantRange based overflow detection for unsigned add/sub

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 14 14:23:08 PDT 2019


nikic created this revision.
nikic added reviewers: spatel, lebedev.ri.
Herald added subscribers: llvm-commits, jdoerfert, hiraditya.
Herald added a project: LLVM.

Based on D59193 <https://reviews.llvm.org/D59193> this makes some improvements to the computeOverflowForUnsignedAdd/Sub functions in ValueTracking:

- The KnownBits are converted into ConstantRanges and the unsigned(Add|Sub)MayOverflow method on ConstantRange is used to determine the overflow condition. This part is NFC because this effectively matches what the code already did in a more explicit way.
- Additionally call computeConstantRange() and intersect it with the KnownBits range.
- Extend computeConstantRange() to compute constant ranges for constant integers and constant integer vectors.

The main tests are based on saturating math intrinsics, though a couple nuw's also get inferred in existing tests.


Repository:
  rL LLVM

https://reviews.llvm.org/D59386

Files:
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/Transforms/InstCombine/and2.ll
  llvm/test/Transforms/InstCombine/saturating-add-sub.ll
  llvm/test/Transforms/LoopVectorize/X86/small-size.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59386.190723.patch
Type: text/x-patch
Size: 11131 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190314/d6e084fd/attachment.bin>


More information about the llvm-commits mailing list