[PATCH] D58593: [ValueTracking] More accurate unsigned add/sub overflow detection

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 24 02:49:22 PST 2019


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

Based on the suggestion in D58329 <https://reviews.llvm.org/D58329>, this changes the existing computeOverflowForUnsignedAdd/Sub methods to detect never/always overflow conditions more accurately.

Rather than calling computeForAddSub() with an extra bit (which would be pretty wasteful, as we're not interested in the addition result here at all), I'm writing out the overflow conditions explicitly.

I've added some explicit tests for saturating add/sub (as we can see both always+never overflow there), but there's also some additional `nuw`s inferred in other tests.


Repository:
  rL LLVM

https://reviews.llvm.org/D58593

Files:
  lib/Analysis/ValueTracking.cpp
  test/Transforms/InstCombine/AddOverFlow.ll
  test/Transforms/InstCombine/demand_shrink_nsw.ll
  test/Transforms/InstCombine/saturating-add-sub.ll
  test/Transforms/InstCombine/sext.ll
  test/Transforms/InstCombine/shuffle_select.ll
  test/Transforms/InstCombine/strlen-1.ll
  test/Transforms/InstCombine/sub-xor.ll
  test/Transforms/InstCombine/wcslen-1.ll
  test/Transforms/InstCombine/wcslen-3.ll
  test/Transforms/LoopVectorize/X86/masked_load_store.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58593.188080.patch
Type: text/x-patch
Size: 12729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190224/2be74810/attachment.bin>


More information about the llvm-commits mailing list