1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
4 ; <rdar://problem/7859988>
6 ; Make sure we don't generate more jumps than we need to. We used to generate
17 ; Now we generate this:
24 define double @rdar_7859988(double %x, double %y) nounwind readnone optsize ssp {
25 ; CHECK-LABEL: rdar_7859988:
26 ; CHECK: # %bb.0: # %entry
27 ; CHECK-NEXT: mulsd %xmm1, %xmm0
28 ; CHECK-NEXT: xorpd %xmm1, %xmm1
29 ; CHECK-NEXT: ucomisd %xmm1, %xmm0
30 ; CHECK-NEXT: jne .LBB0_2
31 ; CHECK-NEXT: jp .LBB0_2
32 ; CHECK-NEXT: # %bb.1: # %bb1
33 ; CHECK-NEXT: addsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
34 ; CHECK-NEXT: .LBB0_2: # %bb2
38 %mul = fmul double %x, %y
39 %cmp = fcmp oeq double %mul, 0.000000e+00
40 br i1 %cmp, label %bb1, label %bb2
43 %add = fadd double %mul, -1.000000e+00
47 %phi = phi double [ %add, %bb1 ], [ %mul, %entry ]
51 define double @profile_metadata(double %x, double %y) {
52 ; CHECK-LABEL: profile_metadata:
53 ; CHECK: # %bb.0: # %entry
54 ; CHECK-NEXT: mulsd %xmm1, %xmm0
55 ; CHECK-NEXT: xorpd %xmm1, %xmm1
56 ; CHECK-NEXT: ucomisd %xmm1, %xmm0
57 ; CHECK-NEXT: jne .LBB1_1
58 ; CHECK-NEXT: jp .LBB1_1
59 ; CHECK-NEXT: # %bb.2: # %bb2
61 ; CHECK-NEXT: .LBB1_1: # %bb1
62 ; CHECK-NEXT: addsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
66 %mul = fmul double %x, %y
67 %cmp = fcmp une double %mul, 0.000000e+00
68 br i1 %cmp, label %bb1, label %bb2, !prof !1
71 %add = fadd double %mul, -1.000000e+00
75 %phi = phi double [ %add, %bb1 ], [ %mul, %entry ]
79 ; Test if the negation of the non-equality check between floating points are
80 ; translated to jnp followed by jne.
82 define void @foo(float %f) {
84 ; CHECK: # %bb.0: # %entry
85 ; CHECK-NEXT: xorps %xmm1, %xmm1
86 ; CHECK-NEXT: ucomiss %xmm1, %xmm0
87 ; CHECK-NEXT: jne .LBB2_2
88 ; CHECK-NEXT: jnp .LBB2_1
89 ; CHECK-NEXT: .LBB2_2: # %if.then
90 ; CHECK-NEXT: jmp a # TAILCALL
91 ; CHECK-NEXT: .LBB2_1: # %if.end
94 %cmp = fcmp une float %f, 0.000000e+00
95 br i1 %cmp, label %if.then, label %if.end
105 ; Test that an FP oeq/une conditional branch can be inverted successfully even
106 ; when the true and false targets are the same (PR27750).
107 define void @pr27750(ptr %b, float %x, i1 %y) {
108 ; CHECK-LABEL: pr27750:
109 ; CHECK: # %bb.0: # %entry
110 ; CHECK-NEXT: xorps %xmm1, %xmm1
111 ; CHECK-NEXT: jmp .LBB3_1
112 ; CHECK-NEXT: .p2align 4, 0x90
113 ; CHECK-NEXT: .LBB3_3: # %for.end
114 ; CHECK-NEXT: # in Loop: Header=BB3_1 Depth=1
115 ; CHECK-NEXT: ucomiss %xmm1, %xmm0
116 ; CHECK-NEXT: jne .LBB3_1
117 ; CHECK-NEXT: jp .LBB3_1
118 ; CHECK-NEXT: .LBB3_1: # %for.cond1
119 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
120 ; CHECK-NEXT: testb $1, %sil
121 ; CHECK-NEXT: je .LBB3_3
122 ; CHECK-NEXT: # %bb.2: # %for.body3.lr.ph
123 ; CHECK-NEXT: # in Loop: Header=BB3_1 Depth=1
124 ; CHECK-NEXT: movl $0, (%rdi)
125 ; CHECK-NEXT: jmp .LBB3_3
133 br i1 %y, label %for.body3.lr.ph, label %for.end
136 store i32 0, ptr %b, align 4
140 ; After block %for.cond gets eliminated, the two target blocks of this
141 ; conditional block are the same.
142 %tobool = fcmp une float %x, 0.000000e+00
143 br i1 %tobool, label %for.cond, label %for.cond1
146 declare dso_local void @a()
148 !1 = !{!"branch_weights", i32 1, i32 1000}