[all-commits] [llvm/llvm-project] c44c1e: [RISCV] Implement isMaskAndCmp0FoldingBeneficial hook

Alex Bradbury via All-commits all-commits at lists.llvm.org
Tue Sep 13 10:55:49 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c44c1e9d3e907f92a23b2fb8536f2e4ccf28380a
      https://github.com/llvm/llvm-project/commit/c44c1e9d3e907f92a23b2fb8536f2e4ccf28380a
  Author: Alex Bradbury <asb at igalia.com>
  Date:   2022-09-13 (Tue, 13 Sep 2022)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    M llvm/lib/Target/RISCV/RISCVISelLowering.h
    A llvm/test/Transforms/CodeGenPrepare/RISCV/and-mask-sink.ll

  Log Message:
  -----------
  [RISCV] Implement isMaskAndCmp0FoldingBeneficial hook

This hook is currently only used by CodeGenPrepare, which will sink *and
duplicate* an 'and' into a block that has an 'icmp 0' user of it if the
hook returns true.

This hook is less useful for RISC-V than for targets like AArch64 that
have a TBZ (test bit and branch if zero instruction), but may still be
profitable if Zbs is available and a BEXTI can be selected.

Conservatively, we return false even if Zbs is enabled for any masks
that fit in the ANDI immediate because it's possible the only use is a
branch on the result, and ANDI+BNEZ => BEXTI+BNEZ isn't a profitable
transformation.

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




More information about the All-commits mailing list