[all-commits] [llvm/llvm-project] 22c590: [RISCV][ISel] Optimize setcc with mask test idioms...

Yingwei Zheng via All-commits all-commits at lists.llvm.org
Fri Jul 4 22:02:19 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 22c590bd3c75ccb6b443e074e4df2c82771a96eb
      https://github.com/llvm/llvm-project/commit/22c590bd3c75ccb6b443e074e4df2c82771a96eb
  Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
  Date:   2025-07-05 (Sat, 05 Jul 2025)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVInstrInfo.td
    M llvm/test/CodeGen/RISCV/GlobalISel/float-intrinsics.ll
    M llvm/test/CodeGen/RISCV/float-intrinsics.ll
    M llvm/test/CodeGen/RISCV/i32-icmp.ll
    M llvm/test/CodeGen/RISCV/i64-icmp.ll
    M llvm/test/CodeGen/RISCV/overflow-intrinsics.ll

  Log Message:
  -----------
  [RISCV][ISel] Optimize setcc with mask test idioms (#147015)

As we are converting more comparisons/differences of pointers into those
of offsets in InstCombine, the mask test idiom `icmp eq/ne (and X,
Mask), 0` may be more common in real-world programs.

This patch eliminates unnecessary srli instructions for this pattern. We
have a similar optimization for `RISCVISD::SELECT_CC/BR_CC`:
https://github.com/llvm/llvm-project/blob/a89e232058a29260eb9bfe77b862715ce875f962/llvm/lib/Target/RISCV/RISCVISelLowering.cpp#L2416-L2446

However, I cannot reuse the function `translateSetCCForBranch` due to
some regressions caused by other DAGCombiner folds:
https://github.com/llvm/llvm-project/compare/main...dtcxzyw:llvm-project:rv-mask-test.
So this patch defers the transformation to ISel.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list