[PATCH] D89317: [InstructionSimplify] icmp simplification

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 13 06:56:40 PDT 2020


SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: spatel, jdoerfert, lebedev.ri, dmgreen, craig.topper.
Herald added subscribers: pengfei, javed.absar, hiraditya.
Herald added a project: LLVM.
SjoerdMeijer requested review of this revision.

This improves simplifications for pattern `icmp (X+Y), (X+Z) -> icmp Y,Z` if only one of the operands has NSW set, e.g.:

  icmp slt (x + 5), (x +nsw 6)

We can still safely rewrite this to:

  icmp slt 5, 6

because we know that the LHS can't overflow if the RHS has NSW set and constant `Y <= Z`.

This is useful because ScalarEvolutionExpander which is used to generate code for SCEVs in different loop optimisers is not always able to put back NSW flags across control-flow.


https://reviews.llvm.org/D89317

Files:
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/test/Transforms/InstSimplify/compare.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89317.297846.patch
Type: text/x-patch
Size: 6014 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201013/8a7e675e/attachment.bin>


More information about the llvm-commits mailing list