1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=arm64-- | FileCheck %s
4 ; This test provides fmf coverage for DAG combining of selects
6 ; select Cond0, (select Cond1, X, Y), Y -> select (and Cond0, Cond1), X, Y
7 define float @select_select_fold_select_and(float %w, float %x, float %y, float %z) {
8 ; CHECK-LABEL: select_select_fold_select_and:
10 ; CHECK-NEXT: fminnm s4, s1, s2
11 ; CHECK-NEXT: fcmp s1, s2
12 ; CHECK-NEXT: fmaxnm s2, s0, s3
13 ; CHECK-NEXT: fmov s1, #0.50000000
14 ; CHECK-NEXT: fccmp s4, s0, #4, lt
15 ; CHECK-NEXT: fadd s1, s0, s1
16 ; CHECK-NEXT: fcsel s2, s2, s0, gt
17 ; CHECK-NEXT: fadd s4, s1, s2
18 ; CHECK-NEXT: fcmp s4, s1
19 ; CHECK-NEXT: b.le .LBB0_2
20 ; CHECK-NEXT: // %bb.1: // %if.then.i157.i.i
21 ; CHECK-NEXT: fmov s0, #1.00000000
22 ; CHECK-NEXT: fadd s0, s2, s0
24 ; CHECK-NEXT: .LBB0_2: // %if.end.i159.i.i
25 ; CHECK-NEXT: mov w8, #52429 // =0xcccd
26 ; CHECK-NEXT: mov w9, #13107 // =0x3333
27 ; CHECK-NEXT: fcmp s1, #0.0
28 ; CHECK-NEXT: movk w8, #48844, lsl #16
29 ; CHECK-NEXT: movk w9, #48819, lsl #16
30 ; CHECK-NEXT: fmov s2, w8
31 ; CHECK-NEXT: fmov s4, w9
32 ; CHECK-NEXT: fadd s0, s0, s2
33 ; CHECK-NEXT: fadd s2, s3, s4
34 ; CHECK-NEXT: fcsel s0, s0, s2, gt
36 %tmp21 = fcmp fast olt float %x, %y
37 %tmp22 = select fast i1 %tmp21, float %x, float %y
38 %tmp24 = fcmp fast ogt float %tmp22, %w
39 %tmp78 = fcmp fast ogt float %w, %z
40 %select0 = select fast i1 %tmp78, float %w, float %z
41 %select1 = select fast i1 %tmp21, float %select0, float %w
42 %select2 = select fast i1 %tmp24, float %select1, float %w
43 %tmp82 = fadd fast float %w, 5.000000e-01
44 %tmp102 = fadd fast float %tmp82, %select2
45 %cmp.i155.i.i = fcmp fast ogt float %tmp102, %tmp82
46 br i1 %cmp.i155.i.i, label %if.then.i157.i.i, label %if.end.i159.i.i
48 if.then.i157.i.i: ; preds = %0
49 %add.i156.i.i = fadd fast float %select2, 1.000000e+00
52 if.end.i159.i.i: ; preds = %0
53 %sub.i158.i.i = fadd fast float %w, 0xBFD99999A0000000
54 %sub15.i.i.i = fadd fast float %z, 0xBFD6666660000000
55 %tmp191 = fcmp fast ogt float %tmp82, 0.000000e+00
56 %select3 = select fast i1 %tmp191, float %sub.i158.i.i, float %sub15.i.i.i
59 exit: ; preds = %if.end.i159.i.i, %if.then.i157.i.i
60 %phi1 = phi float [ %add.i156.i.i, %if.then.i157.i.i ], [ %select3, %if.end.i159.i.i ]
64 ; select Cond0, X, (select Cond1, X, Y) -> select (or Cond0, Cond1), X, Y
65 define float @select_select_fold_select_or(float %w, float %x, float %y, float %z) {
66 ; CHECK-LABEL: select_select_fold_select_or:
68 ; CHECK-NEXT: fminnm s4, s1, s2
69 ; CHECK-NEXT: fcmp s1, s2
70 ; CHECK-NEXT: fmaxnm s2, s0, s3
71 ; CHECK-NEXT: fmov s1, #0.50000000
72 ; CHECK-NEXT: fccmp s4, s0, #0, ge
73 ; CHECK-NEXT: fadd s1, s0, s1
74 ; CHECK-NEXT: fcsel s2, s0, s2, gt
75 ; CHECK-NEXT: fadd s4, s1, s2
76 ; CHECK-NEXT: fcmp s4, s1
77 ; CHECK-NEXT: b.le .LBB1_2
78 ; CHECK-NEXT: // %bb.1: // %if.then.i157.i.i
79 ; CHECK-NEXT: fmov s0, #1.00000000
80 ; CHECK-NEXT: fadd s0, s2, s0
82 ; CHECK-NEXT: .LBB1_2: // %if.end.i159.i.i
83 ; CHECK-NEXT: mov w8, #52429 // =0xcccd
84 ; CHECK-NEXT: mov w9, #13107 // =0x3333
85 ; CHECK-NEXT: fcmp s1, #0.0
86 ; CHECK-NEXT: movk w8, #48844, lsl #16
87 ; CHECK-NEXT: movk w9, #48819, lsl #16
88 ; CHECK-NEXT: fmov s2, w8
89 ; CHECK-NEXT: fmov s4, w9
90 ; CHECK-NEXT: fadd s0, s0, s2
91 ; CHECK-NEXT: fadd s2, s3, s4
92 ; CHECK-NEXT: fcsel s0, s0, s2, gt
94 %tmp21 = fcmp fast olt float %x, %y
95 %tmp22 = select fast i1 %tmp21, float %x, float %y
96 %tmp24 = fcmp fast ogt float %tmp22, %w
97 %tmp78 = fcmp fast ogt float %w, %z
98 %select0 = select fast i1 %tmp78, float %w, float %z
99 %select1 = select fast i1 %tmp21, float %w, float %select0
100 %select2 = select fast i1 %tmp24, float %w, float %select1
101 %tmp82 = fadd fast float %w, 5.000000e-01
102 %tmp102 = fadd fast float %tmp82, %select2
103 %cmp.i155.i.i = fcmp fast ogt float %tmp102, %tmp82
104 br i1 %cmp.i155.i.i, label %if.then.i157.i.i, label %if.end.i159.i.i
106 if.then.i157.i.i: ; preds = %0
107 %add.i156.i.i = fadd fast float %select2, 1.000000e+00
110 if.end.i159.i.i: ; preds = %0
111 %sub.i158.i.i = fadd fast float %w, 0xBFD99999A0000000
112 %sub15.i.i.i = fadd fast float %z, 0xBFD6666660000000
113 %tmp191 = fcmp fast ogt float %tmp82, 0.000000e+00
114 %select3 = select fast i1 %tmp191, float %sub.i158.i.i, float %sub15.i.i.i
117 exit: ; preds = %if.end.i159.i.i, %if.then.i157.i.i
118 %phi1 = phi float [ %add.i156.i.i, %if.then.i157.i.i ], [ %select3, %if.end.i159.i.i ]