[all-commits] [llvm/llvm-project] 2b5960: [RISCV] Branchless lowering for select (and (x , 0...

Philip Reames via All-commits all-commits at lists.llvm.org
Fri Sep 30 08:24:50 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2b5960028ead83ec56c5623b2b8c8c12d91d6ed0
      https://github.com/llvm/llvm-project/commit/2b5960028ead83ec56c5623b2b8c8c12d91d6ed0
  Author: Philip Reames <preames at rivosinc.com>
  Date:   2022-09-30 (Fri, 30 Sep 2022)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    M llvm/test/CodeGen/RISCV/select.ll

  Log Message:
  -----------
  [RISCV] Branchless lowering for select (and (x , 0x1) == 0), y, (z ^ y) ) and select (and (x , 0x1) == 0), y, (z | y) )

This code is directly ported from the X86 backend which applies the same rewrite (along with several others). Planning on looking more closely at the other branchless variants from x86 to see if any are worth porting in future changes.

Motivation here is the coremark crc8 routine from https://github.com/eembc/coremark/blob/main/core_util.c#L165. This patch significantly reduces the number of unpredictable branches in the workload.

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




More information about the All-commits mailing list