[llvm] [RISCV] Fold extract_vector_elt of a load into the scalar load (PR #76151)

Liao Chunyu via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 4 18:37:54 PST 2024


ChunyuLiao wrote:

> 
> I took a brief look in `scalarizeExtractedVectorLoad`, it runs before legalization but **only** for non constant indices and when ISD::LOAD is legal or custom for the element type. So for the test case from this PR:
> 
> ```
> define i32 @variable_index(ptr %v, i32 %i) {
>   %a = load <8 x i32>, ptr %v
>   %b = extractelement <8 x i32> %a, i32 %i
>   ret i32 %b
> }
> ```
> 
> We get a scalar load on RV32, but a vle32 + vslidedown on RV64.
> 
> But I think adding a target combine here makes sense to handle the constant indices case.

Indeed, I didn't notice the difference between rv32 and rv64, and I'll revert non-constant element index and keep constant element index.  thanks. 



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


More information about the llvm-commits mailing list