[all-commits] [llvm/llvm-project] 3369e4: [DAG] Allow XOR(X, MIN_SIGNED_VALUE) to perform Add...

Simon Pilgrim via All-commits all-commits at lists.llvm.org
Wed Apr 6 02:37:26 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3369e474bbd1172175945437783b6841979e654a
      https://github.com/llvm/llvm-project/commit/3369e474bbd1172175945437783b6841979e654a
  Author: Simon Pilgrim <llvm-dev at redking.me.uk>
  Date:   2022-04-06 (Wed, 06 Apr 2022)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    M llvm/test/CodeGen/ARM/dsp-mlal.ll
    M llvm/test/CodeGen/X86/setcc-combine.ll
    M llvm/test/CodeGen/X86/xor-lea.ll

  Log Message:
  -----------
  [DAG] Allow XOR(X,MIN_SIGNED_VALUE) to perform AddLike folds

As raised on PR52267, XOR(X,MIN_SIGNED_VALUE) can be treated as ADD(X,MIN_SIGNED_VALUE), so let these cases use the 'AddLike' folds, similar to how we perform no-common-bits OR(X,Y) cases.

define i8 @src(i8 %x) {
  %r = xor i8 %x, 128
  ret i8 %r
}
=>
define i8 @tgt(i8 %x) {
  %r = add i8 %x, 128
  ret i8 %r
}
Transformation seems to be correct!

https://alive2.llvm.org/ce/z/qV46E2

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




More information about the All-commits mailing list