llvm-project
bde72d41 - [RISCV][GISel] Support scalable vector icmp in the IRTranslator (#247266)

Commit
18 hours ago
[RISCV][GISel] Support scalable vector icmp in the IRTranslator (#247266) Legalization, register bank selection and instruction selection for scalable vector `G_ICMP` were already added in 8aa3a77, 05f673b and 35a9393, with tests in `legalizer/rvv/legalize-icmp.mir`, `regbankselect/rvv/icmp.mir` and `instruction-select/rvv/icmp.mir`. But `fallBackToDAGISel` never allowed `Instruction::ICmp`, so IR `icmp` always fell back to SelectionDAG before reaching them. This patch only adds `ICmp` to that list, plus an IRTranslator test (`irtranslator/vec-icmp.ll`) covering all integer predicates. ```llvm define <vscale x 8 x i1> @icmp_sgt(<vscale x 8 x i8> %a, <vscale x 8 x i8> %b) { %r = icmp sgt <vscale x 8 x i8> %a, %b ret <vscale x 8 x i1> %r } ``` Before (`llc -mtriple=riscv64 -mattr=+v -global-isel -global-isel-abort=1`): ``` LLVM ERROR: unable to translate instruction: icmp (in function: icmp_sgt) ``` After: ```asm icmp_sgt: vsetvli a0, zero, e8, m1, ta, ma vmslt.vv v0, v9, v8 ret ``` Identical to SelectionDAG for all 10 integer predicates on integer vectors up to LMUL 8, RV32 and RV64. Not covered yet (follow-ups): vectors wider than LMUL 8 (no splitting for scalable types, same as `G_ADD`), pointer vectors, and splat operands / mask compares (`G_SPLAT_VECTOR` selection). Part of #246831
Author
Parents
Loading