This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Fallback to scalable lowering costs for fixed length vectors
ClosedPublic

Authored by reames on Mar 13 2023, 9:29 AM.

Details

Summary

Posting this mostly for a sanity check. This seems so obvious that I'm a bit worried I'm missing something.

Note that the new reverse costs do appear to match our actual codegen.

Diff Detail

Event Timeline

reames created this revision.Mar 13 2023, 9:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 13 2023, 9:29 AM
reames requested review of this revision.Mar 13 2023, 9:29 AM
reames added inline comments.Mar 13 2023, 9:30 AM
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
253

Most of the diff is code motion. The only semantic change is removing this if clause and applying this to all vectors after giving the fixed vector code a chance to run.

luke added inline comments.Mar 13 2023, 9:45 AM
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
342–348

Patch makes sense to me.
Just something I saw whilst testing, we don't use vscale with fixed length vectors and could subtract it from the cost:

define <4 x i8> @reverse(<4 x i8> %v0) {
  %v4i8 = shufflevector <4 x i8> %v0, <4 x i8> undef, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
  ret <4 x i8> %v4i8
}
reverse:
	vsetivli	zero, 4, e8, mf4, ta, ma
	vid.v	v9
	vrsub.vi	v10, v9, 3
	vrgather.vv	v9, v8, v10
	vmv1r.v	v8, v9
	ret
luke accepted this revision.Mar 13 2023, 9:45 AM
This revision is now accepted and ready to land.Mar 13 2023, 9:45 AM
This revision was landed with ongoing or failed builds.Mar 13 2023, 10:08 AM
This revision was automatically updated to reflect the committed changes.
reames added inline comments.
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
342–348