[all-commits] [llvm/llvm-project] ddfee0: [InstSimplify] Fold and/or using implied conditions

Nikita Popov via All-commits all-commits at lists.llvm.org
Fri May 13 06:09:33 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ddfee075199db7bd4285bb5b2c739630c5ff9706
      https://github.com/llvm/llvm-project/commit/ddfee075199db7bd4285bb5b2c739630c5ff9706
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2022-05-13 (Fri, 13 May 2022)

  Changed paths:
    M llvm/lib/Analysis/InstructionSimplify.cpp
    M llvm/test/Transforms/InstSimplify/and-icmps-same-ops.ll
    M llvm/test/Transforms/InstSimplify/and-or-implied-cond.ll
    M llvm/test/Transforms/InstSimplify/or-icmps-same-ops.ll

  Log Message:
  -----------
  [InstSimplify] Fold and/or using implied conditions

This adds two conjugated folds:

 * A | B -> B if A implies B (https://alive2.llvm.org/ce/z/R6GU4j)
 * A & B -> A if A implies B (https://alive2.llvm.org/ce/z/EGMqyy)

If A and B are icmps themselves, we will usually fold this through
other logic already (though the tests show a couple additional cases
we previously missed). However, isImpliedCond() also supports A
being of the form X & Y, which allows us to handle cases like
(X & Y) | B where X implies B. This addresses the regression from
D125398.

Something that notably doesn't work yet is the (X | Y) & B case.
This is due to an asymmetry in the isImpliedCondition()
implementation that will have to be addressed separately.

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




More information about the All-commits mailing list