[all-commits] [llvm/llvm-project] 56ea2e: [RISCV] Add a special case to lowerSELECT for sele...

Craig Topper via All-commits all-commits at lists.llvm.org
Wed Apr 7 13:47:43 PDT 2021


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

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    M llvm/test/CodeGen/RISCV/sadd_sat.ll
    M llvm/test/CodeGen/RISCV/sadd_sat_plus.ll
    M llvm/test/CodeGen/RISCV/ssub_sat.ll
    M llvm/test/CodeGen/RISCV/ssub_sat_plus.ll

  Log Message:
  -----------
  [RISCV] Add a special case to lowerSELECT for select of 2 constants with a SETLT condition.

If the constants have a difference of 1 we can convert one to
the other by adding or subtracting the condition.

We have a DAG combine for this, but it only runs before type
legalization. If the select is introduced later during type
legalization or op legalization we will miss it.

We don't need a specific condition, but some conditions are
harder to materialize than others on RISCV. I know that SETLT
will be a single instruction and it is what is used by the
motivating pattern from signed saturating add/sub.

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




More information about the All-commits mailing list