This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Eliminate the extension of index for vector indexed load/store.
Needs ReviewPublic

Authored by jacquesguan on Jun 12 2023, 12:34 AM.

Details

Summary

If the offset vector of vector indexed load/store is an extension, we could eliminate it and use the source operand as the index directly.

Diff Detail

Event Timeline

jacquesguan created this revision.Jun 12 2023, 12:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 12 2023, 12:34 AM
jacquesguan requested review of this revision.Jun 12 2023, 12:34 AM
sorear added a subscriber: sorear.Jun 12 2023, 9:26 PM

Is the SIGN_EXTEND case actually correct? Vector indexed memory operations always zero-extend the index, and the getelementptr doesn't provide enough information to prove the indices are nonnegative.

I think the best we can do without new metadata is

vsetvli zero, a1, e8, m1, ta, ma
addi a0, a0, -128
li a1, -128
vxor.vs v9, v9, a1  # vfneg.v can be used for some SEW
vsoxei8.v v8, (a0), v9, v0.t

Limit to zero_ext.

Is the SIGN_EXTEND case actually correct? Vector indexed memory operations always zero-extend the index, and the getelementptr doesn't provide enough information to prove the indices are nonnegative.

I think the best we can do without new metadata is

vsetvli zero, a1, e8, m1, ta, ma
addi a0, a0, -128
li a1, -128
vxor.vs v9, v9, a1  # vfneg.v can be used for some SEW
vsoxei8.v v8, (a0), v9, v0.t

Yes, I change this patch to match only zero_ext.