[RISCV] Introduce unaligned-vector-mem feature
authorPhilip Reames <preames@rivosinc.com>
Fri, 28 Apr 2023 15:16:48 +0000 (08:16 -0700)
committerPhilip Reames <listmail@philipreames.com>
Fri, 28 Apr 2023 15:28:08 +0000 (08:28 -0700)
commitd636bcb6ae51bf1fe2faff153f3d8f30dc1db8b8
tree9607408a44e8241125d3786a8a1f4dfb0bc077ea
parente161fcde0622a0418b5b20317428dd93b52f31fc
[RISCV] Introduce unaligned-vector-mem feature

This allows us to model and thus test transforms which are legal only when a vector load with less than element alignment are supported. This was originally part of D126085, but was split out as we didn't have a good example of such a transform. As can be seen in the test diffs, we have the recently added concat_vector(loads) -> strided_load transform (from D147713) which now benefits from the unaligned support.

While making this change, I realized that we actually *do* support unaligned vector loads and stores of all types via conversion to i8 element type. For contiguous loads and stores without masking, we actually already implement this in the backend - though we don't tell the optimizer that. For indexed, lowering to i8 requires complicated addressing. For indexed and segmented, we'd have to use indexed. All around, doesn't seem worthwhile pursuing, but makes for an interesting observation.

Differential Revision: https://reviews.llvm.org/D149375
llvm/lib/Target/RISCV/RISCVFeatures.td
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-strided-load-combine.ll
llvm/test/CodeGen/RISCV/rvv/unaligned-loads-stores.ll