[all-commits] [llvm/llvm-project] b7f34c: [InstCombine] Add tests for (binop (binop (lshift ...

goldsteinn via All-commits all-commits at lists.llvm.org
Tue Jun 13 18:08:57 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b7f34cea5a224455d414953d54373da2f42a33a8
      https://github.com/llvm/llvm-project/commit/b7f34cea5a224455d414953d54373da2f42a33a8
  Author: Noah Goldstein <goldstein.w.n at gmail.com>
  Date:   2023-06-13 (Tue, 13 Jun 2023)

  Changed paths:
    A llvm/test/Transforms/InstCombine/binop-and-shifts.ll

  Log Message:
  -----------
  [InstCombine] Add tests for (binop (binop (lshift X,Amt),Mask),(lshift Y,Amt)); NFC

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


  Commit: 91cdffcb2f9ea0b8beac8600d0544c0ae3836682
      https://github.com/llvm/llvm-project/commit/91cdffcb2f9ea0b8beac8600d0544c0ae3836682
  Author: Noah Goldstein <goldstein.w.n at gmail.com>
  Date:   2023-06-13 (Tue, 13 Jun 2023)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineInternal.h
    M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    M llvm/test/Transforms/InstCombine/and-xor-or.ll
    M llvm/test/Transforms/InstCombine/binop-and-shifts.ll
    M llvm/test/Transforms/InstCombine/or-shifted-masks.ll
    M llvm/test/Transforms/PhaseOrdering/SystemZ/sub-xor.ll

  Log Message:
  -----------
  [InstCombine] Transform `(binop1 (binop2 (lshift X,Amt),Mask),(lshift Y,Amt))`

If `Mask` and `Amt` are not constants and `binop1` and `binop2` are
the same we can transform to:
`(binop (lshift (binop X, Y), Amt), Mask)`

If `binop` is `add`, `lshift` must be `shl`.

If `Mask` and `Amt` are constants `C` and `C1` respectively.
We can transform to:
`(lshift1 (binop1 (binop2 X, (inv_lshift1 C, C1), Y)), C1)`

Saving an instruction IFF:
`lshift1` is same opcode as `lshift2`
Either `bitwise1` and/or `bitwise2` is `and`.

Proofs(1/2): https://alive2.llvm.org/ce/z/BjN-m_
Proofs(2/2): https://alive2.llvm.org/ce/z/bZn5QB

This is to help fix the regression caused in D151807

Reviewed By: nikic

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


Compare: https://github.com/llvm/llvm-project/compare/a09f79d2275f...91cdffcb2f9e


More information about the All-commits mailing list