HomePhabricator

[RISCV] Add a special case to lowerSELECT for select of 2 constants with a…

Authored by craig.topper on Wed, Apr 7, 1:46 PM.

Description

[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