This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Extend demanded field transform in InsertVSETVLI to VTYPE subfeilds
ClosedPublic

Authored by reames on Jun 14 2022, 1:25 PM.

Details

Summary

The motivating case, and the only one actually enabled by this patch, is a load or store followed by another op with the same SEW/LMUL ratio.

As an example, consider:

define void @test1(ptr %in, ptr %out) {
entry:
  %0 = load <8 x i16>, ptr %in, align 2
  %1 = sext <8 x i16> %0 to <8 x i32>
  store <8 x i32> %1, ptr %out, align 4
  ret void
}

Without this patch, we get:

	vsetivli	zero, 8, e16, mf4, ta, mu
	vle16.v	v8, (a0)
	vsetvli	zero, zero, e32, mf2, ta, mu
	vsext.vf2	v9, v8
	vse32.v	v9, (a1)
	ret

Whereas with the patch we get:

	vsetivli	zero, 8, e32, mf2, ta, mu
	vle16.v	v8, (a0)
	vsext.vf2	v9, v8
	vse32.v	v9, (a1)
	ret

We have rewritten the first vsetvli and thus removed the second one.

As is strongly hinted by the code structure and todos, I am planning on communing this with all (or most all?) of the cases from isCompatible used in the forward data flow. This will be done in a series of following changes - some NFC reworks, and some reviewed optimization extensions.

Diff Detail

Event Timeline

reames created this revision.Jun 14 2022, 1:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 14 2022, 1:25 PM
reames requested review of this revision.Jun 14 2022, 1:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 14 2022, 1:25 PM
This revision is now accepted and ready to land.Jun 15 2022, 4:43 PM
This revision was landed with ongoing or failed builds.Jun 16 2022, 8:01 AM
This revision was automatically updated to reflect the committed changes.