This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Narrow types of index operand matched pattern (shl (zext), C).
ClosedPublic

Authored by fakepaper56 on Jul 6 2023, 11:34 PM.

Details

Summary

(shl (zext to iXLenVec), C) is a possible pattern in auto-vectorized code for
indexed loads/stores. But extending to iXLen might be too aggressive, RVV
indexed load/store instructions zero extend their indexed operand to XLEN.
The patch tries to narrow the type of the zero extension. It's benefit to
decrease register pressure.

Diff Detail

Event Timeline

fakepaper56 created this revision.Jul 6 2023, 11:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 11:34 PM
fakepaper56 requested review of this revision.Jul 6 2023, 11:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 11:34 PM
craig.topper added inline comments.Jul 7 2023, 12:07 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
10639

extended*

10648

I don't think this should be a TargetConstant.

craig.topper added inline comments.Jul 7 2023, 12:15 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
10634

Can we guarantee Src has an MVT type here? The intrinsic could be used with an illegal zext input type before type legalization.

10635

Can SrcElen be 1 if the input is a mask type before we legalize zero_extend?

12982

I think this should be getMemIntrinsicSDNode to preserve the mem operand.

Address comment.

fakepaper56 marked 2 inline comments as done.

Fix typo.

fakepaper56 marked an inline comment as done.Jul 7 2023, 4:56 AM
fakepaper56 added inline comments.
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
10634

I replaced MVT with EVT.

10635

I think it is acceptable after not using MVT.

craig.topper added inline comments.Jul 7 2023, 8:22 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
10637

Can this create element sizes like i4 or i2?

Avoid generating to i2 or i4 type.

fakepaper56 marked 2 inline comments as done.Jul 7 2023, 9:24 PM
craig.topper added inline comments.Jul 11 2023, 5:55 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
10634

Do we have tests where SrcVT is not an MVT?

10638

Do we have tests for the case where NewElen is less than 8?

fakepaper56 added inline comments.Jul 12 2023, 12:31 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
10634

I think test_vloxei6 and test_vloxei7 in llvm/test/CodeGen/RISCV/rvv/narrow-shift-extend.ll are the case.

10638

I think test_vloxei7 in llvm/test/CodeGen/RISCV/rvv/narrow-shift-extend.ll is the case.

This revision is now accepted and ready to land.Jul 13 2023, 8:57 PM