Skip to content

Commit 6211830

Browse files
committed
[VectorCombine] add reduction-like patterns; NFC
These are based on tests originally included in: D79078
1 parent 9a05547 commit 6211830

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

llvm/test/Transforms/VectorCombine/X86/extract-binop.ll

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,3 +486,64 @@ define <4 x float> @PR34724(<4 x float> %a, <4 x float> %b) {
486486
%v3 = insertelement <4 x float> %v2, float %b23, i32 3
487487
ret <4 x float> %v3
488488
}
489+
490+
define i32 @ext_ext_or_reduction_v4i32(<4 x i32> %x, <4 x i32> %y) {
491+
; CHECK-LABEL: @ext_ext_or_reduction_v4i32(
492+
; CHECK-NEXT: [[Z:%.*]] = and <4 x i32> [[X:%.*]], [[Y:%.*]]
493+
; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x i32> [[Z]], <4 x i32> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
494+
; CHECK-NEXT: [[TMP2:%.*]] = or <4 x i32> [[Z]], [[TMP1]]
495+
; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x i32> [[TMP2]], i32 0
496+
; CHECK-NEXT: [[Z2:%.*]] = extractelement <4 x i32> [[Z]], i32 2
497+
; CHECK-NEXT: [[Z012:%.*]] = or i32 [[TMP3]], [[Z2]]
498+
; CHECK-NEXT: [[Z3:%.*]] = extractelement <4 x i32> [[Z]], i32 3
499+
; CHECK-NEXT: [[Z0123:%.*]] = or i32 [[Z3]], [[Z012]]
500+
; CHECK-NEXT: ret i32 [[Z0123]]
501+
;
502+
%z = and <4 x i32> %x, %y
503+
%z0 = extractelement <4 x i32> %z, i32 0
504+
%z1 = extractelement <4 x i32> %z, i32 1
505+
%z01 = or i32 %z0, %z1
506+
%z2 = extractelement <4 x i32> %z, i32 2
507+
%z012 = or i32 %z01, %z2
508+
%z3 = extractelement <4 x i32> %z, i32 3
509+
%z0123 = or i32 %z3, %z012
510+
ret i32 %z0123
511+
}
512+
513+
define i32 @ext_ext_partial_add_reduction_v4i32(<4 x i32> %x) {
514+
; CHECK-LABEL: @ext_ext_partial_add_reduction_v4i32(
515+
; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
516+
; CHECK-NEXT: [[TMP2:%.*]] = add <4 x i32> [[TMP1]], [[X]]
517+
; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x i32> [[TMP2]], i64 0
518+
; CHECK-NEXT: [[X2:%.*]] = extractelement <4 x i32> [[X]], i32 2
519+
; CHECK-NEXT: [[X210:%.*]] = add i32 [[X2]], [[TMP3]]
520+
; CHECK-NEXT: ret i32 [[X210]]
521+
;
522+
%x0 = extractelement <4 x i32> %x, i32 0
523+
%x1 = extractelement <4 x i32> %x, i32 1
524+
%x10 = add i32 %x1, %x0
525+
%x2 = extractelement <4 x i32> %x, i32 2
526+
%x210 = add i32 %x2, %x10
527+
ret i32 %x210
528+
}
529+
530+
define i32 @ext_ext_partial_add_reduction_and_extra_add_v4i32(<4 x i32> %x, <4 x i32> %y) {
531+
; CHECK-LABEL: @ext_ext_partial_add_reduction_and_extra_add_v4i32(
532+
; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x i32> [[Y:%.*]], <4 x i32> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
533+
; CHECK-NEXT: [[TMP2:%.*]] = add <4 x i32> [[TMP1]], [[Y]]
534+
; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x i32> [[TMP2]], i64 0
535+
; CHECK-NEXT: [[Y2:%.*]] = extractelement <4 x i32> [[Y]], i32 2
536+
; CHECK-NEXT: [[Y210:%.*]] = add i32 [[Y2]], [[TMP3]]
537+
; CHECK-NEXT: [[X2:%.*]] = extractelement <4 x i32> [[X:%.*]], i32 2
538+
; CHECK-NEXT: [[X2Y210:%.*]] = add i32 [[X2]], [[Y210]]
539+
; CHECK-NEXT: ret i32 [[X2Y210]]
540+
;
541+
%y0 = extractelement <4 x i32> %y, i32 0
542+
%y1 = extractelement <4 x i32> %y, i32 1
543+
%y10 = add i32 %y1, %y0
544+
%y2 = extractelement <4 x i32> %y, i32 2
545+
%y210 = add i32 %y2, %y10
546+
%x2 = extractelement <4 x i32> %x, i32 2
547+
%x2y210 = add i32 %x2, %y210
548+
ret i32 %x2y210
549+
}

0 commit comments

Comments
 (0)