[all-commits] [llvm/llvm-project] 892648: [InstSimplify] fold xor logic of 2 variables

RotateRight via All-commits all-commits at lists.llvm.org
Tue Nov 23 13:51:40 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 892648b18a8cc3b8a08528112adfa74bdd432f8b
      https://github.com/llvm/llvm-project/commit/892648b18a8cc3b8a08528112adfa74bdd432f8b
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2021-11-23 (Tue, 23 Nov 2021)

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

  Log Message:
  -----------
  [InstSimplify] fold xor logic of 2 variables

(a & b) ^ (~a | b) --> ~a

I was looking for a shortcut to reduce some of the complex logic
folds that are currently up for review (D113216
and others in that stack), and I found this missing from
instcombine/instsimplify.

There is a trade-off in putting it into instsimplify: because
we can't create new values here, we need a strict 'not' op (no
undef elements). Otherwise, the fold is not valid:
https://alive2.llvm.org/ce/z/k_AGGj

If this was in instcombine instead, we could create the proper
'not'. But having the fold here benefits other passes like GVN
that use instsimplify as an analysis.

There is a related fold where 'and' and 'or' are swapped, and
that is planned as a follow-up commit.

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




More information about the All-commits mailing list