[all-commits] [llvm/llvm-project] 51d7df: [InstructionSimplify] icmp (X+Y), (X+Z) simplifica...

sjoerdmeijer via All-commits all-commits at lists.llvm.org
Thu Oct 22 01:06:02 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 51d7df3fa1c3ebd65f72c021074b7aeb43dac8c3
      https://github.com/llvm/llvm-project/commit/51d7df3fa1c3ebd65f72c021074b7aeb43dac8c3
  Author: Sjoerd Meijer <sjoerd.meijer at arm.com>
  Date:   2020-10-22 (Thu, 22 Oct 2020)

  Changed paths:
    M llvm/lib/Analysis/InstructionSimplify.cpp
    M llvm/test/Transforms/InstSimplify/compare.ll

  Log Message:
  -----------
  [InstructionSimplify] icmp (X+Y), (X+Z) simplification

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 + 0), (x +nsw 1)

We can still safely rewrite this to:

    icmp slt 0, 1

because we know that the LHS can't overflow if the RHS has NSW set and
C1 < C2 && C1 >= 0, or C2 < C1 && C1 <= 0

This simplification 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, thus inhibiting CFG simplifications.

Differential Revision: https://reviews.llvm.org/D89317




More information about the All-commits mailing list