[all-commits] [llvm/llvm-project] 60216a: [RISCV] Add test cases for D101485. NFC

Craig Topper via All-commits all-commits at lists.llvm.org
Thu Apr 29 09:47:19 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 60216adef1c8599eaf6d183dad546c1dafd81964
      https://github.com/llvm/llvm-project/commit/60216adef1c8599eaf6d183dad546c1dafd81964
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2021-04-29 (Thu, 29 Apr 2021)

  Changed paths:
    A llvm/test/CodeGen/RISCV/select-binop-identity.ll

  Log Message:
  -----------
  [RISCV] Add test cases for D101485. NFC


  Commit: dcdda2bdf236492f595c361cdddd316ada441137
      https://github.com/llvm/llvm-project/commit/dcdda2bdf236492f595c361cdddd316ada441137
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2021-04-29 (Thu, 29 Apr 2021)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    M llvm/test/CodeGen/RISCV/rv32zbb-zbp.ll
    M llvm/test/CodeGen/RISCV/rv32zbs.ll
    M llvm/test/CodeGen/RISCV/rv32zbt.ll
    M llvm/test/CodeGen/RISCV/select-binop-identity.ll

  Log Message:
  -----------
  [RISCV] Teach DAG combine to fold (and (select_cc lhs, rhs, cc, -1, c), x) -> (select_cc lhs, rhs, cc, x, (and, x, c))

Similar for or/xor with 0 in place of -1.

This is the canonical form produced by InstCombine for something like `c ? x & y : x;` Since we have to use control flow to expand select we'll usually end up with a mv in basic block. By folding this we may be able to pull the and/or/xor into the block instead and avoid a mv instruction.

The code here is based on code from ARM that uses this to create predicated instructions. I'm doing it on SELECT_CC so it happens late, but we could do it on select earlier which is what ARM does. I'm not sure if we lose any combine opportunities if we do it earlier.

I left out add and sub because this can separate sext.w from the add/sub. It also made a conditional i64 addition/subtraction on RV32 worse. I guess both of those would be fixed by doing this earlier on select.

The select-binop-identity.ll test has not been commited yet, but I made the diff show the changes to it.

Reviewed By: luismarques

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


Compare: https://github.com/llvm/llvm-project/compare/923993222179...dcdda2bdf236


More information about the All-commits mailing list