This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add support for matching vwmaccsu/vwmaccus from fixed vectors
ClosedPublic

Authored by Chenbing.Zheng on Feb 8 2022, 10:37 PM.

Details

Summary

Add pattern to match add and widening mul to vwmacc, and
two multipliers are sext and zext.

Diff Detail

Event Timeline

Chenbing.Zheng created this revision.Feb 8 2022, 10:37 PM
Chenbing.Zheng requested review of this revision.Feb 8 2022, 10:37 PM

What about vwmaccus.vx?

What about vwmaccus.vx?

Apply this patch,it will produce vmv.v.x and vwmaccsu.vv instead of vwmaccus.vx. May I solve it in another patch?

define <2 x i16> @vwmaccus_vx_v2i16(<2 x i8>* %x, i8 %y, <2 x i16> %z) {
; CHECK-LABEL: vwmaccus_vx_v2i16:
; CHECK: # %bb.0:
; CHECK-NEXT: vsetivli zero, 2, e8, mf8, ta, mu
; CHECK-NEXT: vle8.v v9, (a0)
; CHECK-NEXT: vmv.v.x v10, a1
; CHECK-NEXT: vwmaccsu.vv v8, v9, v10
; CHECK-NEXT: ret

%a = load <2 x i8>, <2 x i8>* %x
%b = insertelement <2 x i8> poison, i8 %y, i32 0
%c = shufflevector <2 x i8> %b, <2 x i8> poison, <2 x i32> zeroinitializer
%d = sext <2 x i8> %a to <2 x i16>
%e = zext <2 x i8> %c to <2 x i16>
%f = mul <2 x i16> %d, %e
%g = add <2 x i16> %f, %z
ret <2 x i16> %g

}

What about vwmaccus.vx?

Apply this patch,it will produce vmv.v.x and vwmaccsu.vv instead of vwmaccus.vx. May I solve it in another patch?

define <2 x i16> @vwmaccus_vx_v2i16(<2 x i8>* %x, i8 %y, <2 x i16> %z) {
; CHECK-LABEL: vwmaccus_vx_v2i16:
; CHECK: # %bb.0:
; CHECK-NEXT: vsetivli zero, 2, e8, mf8, ta, mu
; CHECK-NEXT: vle8.v v9, (a0)
; CHECK-NEXT: vmv.v.x v10, a1
; CHECK-NEXT: vwmaccsu.vv v8, v9, v10
; CHECK-NEXT: ret

%a = load <2 x i8>, <2 x i8>* %x
%b = insertelement <2 x i8> poison, i8 %y, i32 0
%c = shufflevector <2 x i8> %b, <2 x i8> poison, <2 x i32> zeroinitializer
%d = sext <2 x i8> %a to <2 x i16>
%e = zext <2 x i8> %c to <2 x i16>
%f = mul <2 x i16> %d, %e
%g = add <2 x i16> %f, %z
ret <2 x i16> %g

}

Don't you just need to add another isel pattern to handle it? What's preventing that being part of of this patch?

Chenbing.Zheng retitled this revision from [RISCV] Add support for matching vwmaccsu from fixed vectors to [RISCV] Add support for matching vwmaccsu/vwmaccus from fixed vectors.

add vwmaccus

This revision is now accepted and ready to land.Feb 9 2022, 11:05 AM
This revision was landed with ongoing or failed builds.Feb 9 2022, 5:59 PM
This revision was automatically updated to reflect the committed changes.