[llvm] [RISCV][GISel] Select G_SELECT (G_ICMP, A, B) (PR #68247)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 4 16:54:21 PDT 2023


topperc wrote:

> This approach works, but we could probably get the same functionality by importing the required SelectionDAG patterns. Patterns like this:
> 
> ```
> def : SelectCompressOpt<SETEQ>
> ```
> 
> fail to import since we don't have an equivalent instruction for `RISCVISD::SELECT_CC`. We could create an equivalent generic instruction to fix that.
> 
> It would be good because then we don't reinvent this wheel, but it also means we're committing to having -O3 selection for G_SELECT at all optimization levels (since SelectionDAG behaves invariantly on optimization levels). We briefly discussed in the past whether any combine that depends on a previous instruction should be at -O1, but we didn't commit to any decision back then.
> 
> I like the approach you've chosen because it lets us be more granular about our optimization levels. I just thought I'd drop this here so that we're all aware of the design choices here.

There aren't SelectionDAG patterns for everything. The majority of the code in this patch is the equivalent of LowerSelect and translateSetCCForBranch from SelectionDAG. So adding an equivalent of `RISCVISD::SELECT_CC` wouldn't reduce any code. It would just move it around.

https://github.com/llvm/llvm-project/pull/68247


More information about the llvm-commits mailing list