[PATCH] D116322: [Analysis] allow caller to choose signed/unsigned when computing constant range

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 27 13:36:50 PST 2021


spatel created this revision.
spatel added reviewers: nikic, lebedev.ri.
Herald added subscribers: jeroen.dobbelaere, hiraditya, mcrosier.
spatel requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

We should not lose analysis precision if an 'add' has both no-wrap flags (nsw and nuw) compared to just one or the other.

This patch is modeled on a similar construct that was added with D59386 <https://reviews.llvm.org/D59386>.

I don't think it is possible to expose a problem with an unsigned compare because of the way this was coded (nuw is handled first).

InstCombine has an assert that fires with the example from:
https://github.com/llvm/llvm-project/issues/52884
...because it was expecting InstSimplify to handle this kind of pattern with an smax.


https://reviews.llvm.org/D116322

Files:
  llvm/include/llvm/Analysis/ValueTracking.h
  llvm/lib/Analysis/BasicAliasAnalysis.cpp
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/Transforms/Vectorize/VectorCombine.cpp
  llvm/test/Transforms/InstCombine/minmax-intrinsics.ll
  llvm/test/Transforms/InstSimplify/icmp-constant.ll
  llvm/unittests/Analysis/ValueTrackingTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116322.396334.patch
Type: text/x-patch
Size: 11109 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211227/465278ba/attachment.bin>


More information about the llvm-commits mailing list