Skip to content

Commit 989bd58

Browse files
committed
Add new mixed vector element tests
Add test-cases for the newly added elementwise optimizations covering vectors like <poison, Inf> and <poison, Inf, SNaN>.
1 parent d3c2f6f commit 989bd58

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

llvm/test/Transforms/InstSimplify/fminmax-folds.ll

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,80 @@ define void @minmax_neg_largest_nxv2f32_nnan_ninf(<vscale x 2 x float> %x, ptr %
584584
ret void
585585
}
586586

587+
;###############################################################
588+
;# Mixed Constant Vector Elements #
589+
;###############################################################
590+
; Tests elementwise handling of different combinations of the above optimizable constants
591+
592+
; Test with vector variants (v2f64) with +Inf and poison
593+
; Poison element allows for flexibility to choose either X or <poison, +Inf> where applicable
594+
define void @minmax_mixed_pos_inf_poison_v2f64_nnan(<2 x double> %x, ptr %minnum_res, ptr %maxnum_res, ptr %minimum_res, ptr %maximum_res, ptr %minimumnum_res, ptr %maximumnum_res) {
595+
; CHECK-LABEL: @minmax_mixed_pos_inf_poison_v2f64_nnan(
596+
; CHECK-NEXT: store <2 x double> [[X:%.*]], ptr [[MINNUM_RES:%.*]], align 16
597+
; CHECK-NEXT: store <2 x double> <double poison, double 0x7FF0000000000000>, ptr [[MAXNUM_RES:%.*]], align 16
598+
; CHECK-NEXT: store <2 x double> [[X]], ptr [[MINIMUM_RES:%.*]], align 16
599+
; CHECK-NEXT: store <2 x double> <double poison, double 0x7FF0000000000000>, ptr [[MAXIMUM_RES:%.*]], align 16
600+
; CHECK-NEXT: store <2 x double> [[X]], ptr [[MINIMUMNUM_RES:%.*]], align 16
601+
; CHECK-NEXT: store <2 x double> <double poison, double 0x7FF0000000000000>, ptr [[MAXIMUMNUM_RES:%.*]], align 16
602+
; CHECK-NEXT: ret void
603+
;
604+
%minnum = call nnan <2 x double> @llvm.minnum.v2f64(<2 x double> <double poison, double 0x7FF0000000000000>, <2 x double> %x)
605+
store <2 x double> %minnum, ptr %minnum_res
606+
%maxnum = call nnan <2 x double> @llvm.maxnum.v2f64(<2 x double> <double poison, double 0x7FF0000000000000>, <2 x double> %x)
607+
store <2 x double> %maxnum, ptr %maxnum_res
608+
609+
%minimum = call nnan <2 x double> @llvm.minimum.v2f64(<2 x double> <double poison, double 0x7FF0000000000000>, <2 x double> %x)
610+
store <2 x double> %minimum, ptr %minimum_res
611+
%maximum = call nnan <2 x double> @llvm.maximum.v2f64(<2 x double> <double poison, double 0x7FF0000000000000>, <2 x double> %x)
612+
store <2 x double> %maximum, ptr %maximum_res
613+
614+
%minimumnum = call nnan <2 x double> @llvm.minimumnum.v2f64(<2 x double> <double poison, double 0x7FF0000000000000>, <2 x double> %x)
615+
store <2 x double> %minimumnum, ptr %minimumnum_res
616+
%maximumnum = call nnan <2 x double> @llvm.maximumnum.v2f64(<2 x double> <double poison, double 0x7FF0000000000000>, <2 x double> %x)
617+
store <2 x double> %maximumnum, ptr %maximumnum_res
618+
ret void
619+
}
620+
621+
; Tests to show that we can optimize different classes of constatn (inf/nan/poison) in different vector elements.
622+
; We can only optimize if the result would be choosing all elements of the input X, or all constant elements though
623+
; (where poison allows us to choose either).
624+
;
625+
; nnan minnum(<poison, +Inf, SNaN>, X) = <???, X1, QNaN> (Cannot mix elements from X and constant vector)
626+
; nnan maxnum(<poison, +Inf, SNaN>, X) = <poison +Inf, QNaN>
627+
; nnan minimum(<poison, +Inf, SNaN>, X) = <???, X1, QNaN> (Cannot mix elements from X and constant vector)
628+
; nnan maximum(<poison, +Inf, SNaN>, X) = <poison +Inf, QNaN>
629+
; nnan minimumnum(<poison, +Inf, SNaN>, X) = <X0, X1, X2> (Poison can be either X or constant value)
630+
; nnan maximumnum(<poison, +Inf, SNaN>, X) = <???, +Inf, X2>
631+
define void @minmax_mixed_pos_inf_poison_snan_v3f32(<3 x float> %x, ptr %minnum_res, ptr %maxnum_res, ptr %minimum_res, ptr %maximum_res, ptr %minimumnum_res, ptr %maximumnum_res) {
632+
; CHECK-LABEL: @minmax_mixed_pos_inf_poison_snan_v3f32(
633+
; CHECK-NEXT: [[MINNUM:%.*]] = call nnan <3 x float> @llvm.minnum.v3f32(<3 x float> <float poison, float 0x7FF0000000000000, float 0x7FF4000000000000>, <3 x float> [[X:%.*]])
634+
; CHECK-NEXT: store <3 x float> [[MINNUM]], ptr [[MINNUM_RES:%.*]], align 16
635+
; CHECK-NEXT: store <3 x float> <float poison, float 0x7FF0000000000000, float 0x7FFC000000000000>, ptr [[MAXNUM_RES:%.*]], align 16
636+
; CHECK-NEXT: [[MINIMUM:%.*]] = call nnan <3 x float> @llvm.minimum.v3f32(<3 x float> <float poison, float 0x7FF0000000000000, float 0x7FF4000000000000>, <3 x float> [[X]])
637+
; CHECK-NEXT: store <3 x float> [[MINIMUM]], ptr [[MINIMUM_RES:%.*]], align 16
638+
; CHECK-NEXT: store <3 x float> <float poison, float 0x7FF0000000000000, float 0x7FFC000000000000>, ptr [[MAXIMUM_RES:%.*]], align 16
639+
; CHECK-NEXT: store <3 x float> [[X]], ptr [[MINIMUMNUM_RES:%.*]], align 16
640+
; CHECK-NEXT: [[MAXIMUMNUM:%.*]] = call nnan <3 x float> @llvm.maximumnum.v3f32(<3 x float> <float poison, float 0x7FF0000000000000, float 0x7FF4000000000000>, <3 x float> [[X]])
641+
; CHECK-NEXT: store <3 x float> [[MAXIMUMNUM]], ptr [[MAXIMUMNUM_RES:%.*]], align 16
642+
; CHECK-NEXT: ret void
643+
;
644+
%minnum = call nnan <3 x float> @llvm.minnum.v3f32(<3 x float> <float poison, float 0x7FF0000000000000, float 0x7FF4000000000000>, <3 x float> %x)
645+
store <3 x float> %minnum, ptr %minnum_res
646+
%maxnum = call nnan <3 x float> @llvm.maxnum.v3f32(<3 x float> <float poison, float 0x7FF0000000000000, float 0x7FF4000000000000>, <3 x float> %x)
647+
store <3 x float> %maxnum, ptr %maxnum_res
648+
649+
%minimum = call nnan <3 x float> @llvm.minimum.v3f32(<3 x float> <float poison, float 0x7FF0000000000000, float 0x7FF4000000000000>, <3 x float> %x)
650+
store <3 x float> %minimum, ptr %minimum_res
651+
%maximum = call nnan <3 x float> @llvm.maximum.v3f32(<3 x float> <float poison, float 0x7FF0000000000000, float 0x7FF4000000000000>, <3 x float> %x)
652+
store <3 x float> %maximum, ptr %maximum_res
653+
654+
%minimumnum = call nnan <3 x float> @llvm.minimumnum.v3f32(<3 x float> <float poison, float 0x7FF0000000000000, float 0x7FF4000000000000>, <3 x float> %x)
655+
store <3 x float> %minimumnum, ptr %minimumnum_res
656+
%maximumnum = call nnan <3 x float> @llvm.maximumnum.v3f32(<3 x float> <float poison, float 0x7FF0000000000000, float 0x7FF4000000000000>, <3 x float> %x)
657+
store <3 x float> %maximumnum, ptr %maximumnum_res
658+
ret void
659+
}
660+
587661
;###############################################################
588662
;# Min(x, x) / Max(x, x) #
589663
;###############################################################

0 commit comments

Comments
 (0)