xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/fp-une-cmp.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker; <rdar://problem/7859988>
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker; Make sure we don't generate more jumps than we need to. We used to generate
7*9880d681SAndroid Build Coastguard Worker; something like this:
8*9880d681SAndroid Build Coastguard Worker;
9*9880d681SAndroid Build Coastguard Worker;       jne  LBB0_1
10*9880d681SAndroid Build Coastguard Worker;       jnp  LBB0_2
11*9880d681SAndroid Build Coastguard Worker;   LBB0_1:
12*9880d681SAndroid Build Coastguard Worker;       jmp  LBB0_3
13*9880d681SAndroid Build Coastguard Worker;   LBB0_2:
14*9880d681SAndroid Build Coastguard Worker;       addsd ...
15*9880d681SAndroid Build Coastguard Worker;   LBB0_3:
16*9880d681SAndroid Build Coastguard Worker;
17*9880d681SAndroid Build Coastguard Worker; Now we generate this:
18*9880d681SAndroid Build Coastguard Worker;
19*9880d681SAndroid Build Coastguard Worker;       jne  LBB0_2
20*9880d681SAndroid Build Coastguard Worker;       jp   LBB0_2
21*9880d681SAndroid Build Coastguard Worker;       addsd ...
22*9880d681SAndroid Build Coastguard Worker;   LBB0_2:
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Workerdefine double @rdar_7859988(double %x, double %y) nounwind readnone optsize ssp {
25*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: rdar_7859988:
26*9880d681SAndroid Build Coastguard Worker; CHECK:       # BB#0: # %entry
27*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    mulsd %xmm1, %xmm0
28*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    xorpd %xmm1, %xmm1
29*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    ucomisd %xmm1, %xmm0
30*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    jne .LBB0_2
31*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    jp .LBB0_2
32*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  # BB#1: # %bb1
33*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    addsd {{.*}}(%rip), %xmm0
34*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  .LBB0_2: # %bb2
35*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    retq
36*9880d681SAndroid Build Coastguard Worker
37*9880d681SAndroid Build Coastguard Workerentry:
38*9880d681SAndroid Build Coastguard Worker  %mul = fmul double %x, %y
39*9880d681SAndroid Build Coastguard Worker  %cmp = fcmp une double %mul, 0.000000e+00
40*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %bb2, label %bb1
41*9880d681SAndroid Build Coastguard Worker
42*9880d681SAndroid Build Coastguard Workerbb1:
43*9880d681SAndroid Build Coastguard Worker  %add = fadd double %mul, -1.000000e+00
44*9880d681SAndroid Build Coastguard Worker  br label %bb2
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Workerbb2:
47*9880d681SAndroid Build Coastguard Worker  %phi = phi double [ %add, %bb1 ], [ %mul, %entry ]
48*9880d681SAndroid Build Coastguard Worker  ret double %phi
49*9880d681SAndroid Build Coastguard Worker}
50*9880d681SAndroid Build Coastguard Worker
51*9880d681SAndroid Build Coastguard Workerdefine double @profile_metadata(double %x, double %y) {
52*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: profile_metadata:
53*9880d681SAndroid Build Coastguard Worker; CHECK:       # BB#0: # %entry
54*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    mulsd %xmm1, %xmm0
55*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    xorpd %xmm1, %xmm1
56*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    ucomisd %xmm1, %xmm0
57*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    jne .LBB1_1
58*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    jp .LBB1_1
59*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  .LBB1_2: # %bb2
60*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    retq
61*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  .LBB1_1: # %bb1
62*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    addsd {{.*}}(%rip), %xmm0
63*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    jmp .LBB1_2
64*9880d681SAndroid Build Coastguard Worker
65*9880d681SAndroid Build Coastguard Workerentry:
66*9880d681SAndroid Build Coastguard Worker  %mul = fmul double %x, %y
67*9880d681SAndroid Build Coastguard Worker  %cmp = fcmp une double %mul, 0.000000e+00
68*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %bb1, label %bb2, !prof !1
69*9880d681SAndroid Build Coastguard Worker
70*9880d681SAndroid Build Coastguard Workerbb1:
71*9880d681SAndroid Build Coastguard Worker  %add = fadd double %mul, -1.000000e+00
72*9880d681SAndroid Build Coastguard Worker  br label %bb2
73*9880d681SAndroid Build Coastguard Worker
74*9880d681SAndroid Build Coastguard Workerbb2:
75*9880d681SAndroid Build Coastguard Worker  %phi = phi double [ %add, %bb1 ], [ %mul, %entry ]
76*9880d681SAndroid Build Coastguard Worker  ret double %phi
77*9880d681SAndroid Build Coastguard Worker}
78*9880d681SAndroid Build Coastguard Worker
79*9880d681SAndroid Build Coastguard Worker; Test if the negation of the non-equality check between floating points are
80*9880d681SAndroid Build Coastguard Worker; translated to jnp followed by jne.
81*9880d681SAndroid Build Coastguard Worker
82*9880d681SAndroid Build Coastguard Workerdefine void @foo(float %f) {
83*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: foo:
84*9880d681SAndroid Build Coastguard Worker; CHECK:       # BB#0: # %entry
85*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    xorps %xmm1, %xmm1
86*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    ucomiss %xmm1, %xmm0
87*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    jne .LBB2_2
88*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    jnp .LBB2_1
89*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  .LBB2_2: # %if.then
90*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    jmp a # TAILCALL
91*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  .LBB2_1: # %if.end
92*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    retq
93*9880d681SAndroid Build Coastguard Workerentry:
94*9880d681SAndroid Build Coastguard Worker  %cmp = fcmp une float %f, 0.000000e+00
95*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %if.then, label %if.end
96*9880d681SAndroid Build Coastguard Worker
97*9880d681SAndroid Build Coastguard Workerif.then:
98*9880d681SAndroid Build Coastguard Worker  tail call void @a()
99*9880d681SAndroid Build Coastguard Worker  br label %if.end
100*9880d681SAndroid Build Coastguard Worker
101*9880d681SAndroid Build Coastguard Workerif.end:
102*9880d681SAndroid Build Coastguard Worker  ret void
103*9880d681SAndroid Build Coastguard Worker}
104*9880d681SAndroid Build Coastguard Worker
105*9880d681SAndroid Build Coastguard Worker; Test that an FP oeq/une conditional branch can be inverted successfully even
106*9880d681SAndroid Build Coastguard Worker; when the true and false targets are the same (PR27750).
107*9880d681SAndroid Build Coastguard Worker;
108*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: pr27750
109*9880d681SAndroid Build Coastguard Worker; CHECK: ucomiss
110*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: jne [[TARGET:.*]]
111*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: jp [[TARGET]]
112*9880d681SAndroid Build Coastguard Workerdefine void @pr27750(i32* %b, float %x, i1 %y) {
113*9880d681SAndroid Build Coastguard Workerentry:
114*9880d681SAndroid Build Coastguard Worker  br label %for.cond
115*9880d681SAndroid Build Coastguard Worker
116*9880d681SAndroid Build Coastguard Workerfor.cond:
117*9880d681SAndroid Build Coastguard Worker  br label %for.cond1
118*9880d681SAndroid Build Coastguard Worker
119*9880d681SAndroid Build Coastguard Workerfor.cond1:
120*9880d681SAndroid Build Coastguard Worker  br i1 %y, label %for.body3.lr.ph, label %for.end
121*9880d681SAndroid Build Coastguard Worker
122*9880d681SAndroid Build Coastguard Workerfor.body3.lr.ph:
123*9880d681SAndroid Build Coastguard Worker  store i32 0, i32* %b, align 4
124*9880d681SAndroid Build Coastguard Worker  br label %for.end
125*9880d681SAndroid Build Coastguard Worker
126*9880d681SAndroid Build Coastguard Workerfor.end:
127*9880d681SAndroid Build Coastguard Worker; After block %for.cond gets eliminated, the two target blocks of this
128*9880d681SAndroid Build Coastguard Worker; conditional block are the same.
129*9880d681SAndroid Build Coastguard Worker  %tobool = fcmp une float %x, 0.000000e+00
130*9880d681SAndroid Build Coastguard Worker  br i1 %tobool, label %for.cond, label %for.cond1
131*9880d681SAndroid Build Coastguard Worker}
132*9880d681SAndroid Build Coastguard Worker
133*9880d681SAndroid Build Coastguard Workerdeclare void @a()
134*9880d681SAndroid Build Coastguard Worker
135*9880d681SAndroid Build Coastguard Worker!1 = !{!"branch_weights", i32 1, i32 1000}
136