xref: /aosp_15_r20/external/llvm/test/CodeGen/AArch64/fcmp.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -verify-machineinstrs -o - %s -mtriple=aarch64-none-linux-gnu | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Workerdeclare void @bar(i32)
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Workerdefine void @test_float(float %a, float %b) {
6*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_float:
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Worker  %tst1 = fcmp oeq float %a, %b
9*9880d681SAndroid Build Coastguard Worker  br i1 %tst1, label %end, label %t2
10*9880d681SAndroid Build Coastguard Worker; CHECK: fcmp {{s[0-9]+}}, {{s[0-9]+}}
11*9880d681SAndroid Build Coastguard Worker; CHECK: b.eq .L
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Workert2:
14*9880d681SAndroid Build Coastguard Worker  %tst2 = fcmp une float %b, 0.0
15*9880d681SAndroid Build Coastguard Worker  br i1 %tst2, label %t3, label %end
16*9880d681SAndroid Build Coastguard Worker; CHECK: fcmp {{s[0-9]+}}, #0.0
17*9880d681SAndroid Build Coastguard Worker; CHECK: b.eq .L
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Workert3:
21*9880d681SAndroid Build Coastguard Worker; This test can't be implemented with just one A64 conditional
22*9880d681SAndroid Build Coastguard Worker; branch. LLVM converts "ordered and not equal" to "unordered or
23*9880d681SAndroid Build Coastguard Worker; equal" before instruction selection, which is what we currently
24*9880d681SAndroid Build Coastguard Worker; test. Obviously, other sequences are valid.
25*9880d681SAndroid Build Coastguard Worker  %tst3 = fcmp one float %a,  %b
26*9880d681SAndroid Build Coastguard Worker  br i1 %tst3, label %t4, label %end
27*9880d681SAndroid Build Coastguard Worker; CHECK: fcmp {{s[0-9]+}}, {{s[0-9]+}}
28*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: b.eq .[[T4:LBB[0-9]+_[0-9]+]]
29*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: b.vs .[[T4]]
30*9880d681SAndroid Build Coastguard Workert4:
31*9880d681SAndroid Build Coastguard Worker  %tst4 = fcmp uge float %a, -0.0
32*9880d681SAndroid Build Coastguard Worker  br i1 %tst4, label %t5, label %end
33*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: fcmp {{s[0-9]+}}, #0.0
34*9880d681SAndroid Build Coastguard Worker; CHECK: b.mi .LBB
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Workert5:
37*9880d681SAndroid Build Coastguard Worker  call void @bar(i32 0)
38*9880d681SAndroid Build Coastguard Worker  ret void
39*9880d681SAndroid Build Coastguard Workerend:
40*9880d681SAndroid Build Coastguard Worker  ret void
41*9880d681SAndroid Build Coastguard Worker
42*9880d681SAndroid Build Coastguard Worker}
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Workerdefine void @test_double(double %a, double %b) {
45*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_double:
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Worker  %tst1 = fcmp oeq double %a, %b
48*9880d681SAndroid Build Coastguard Worker  br i1 %tst1, label %end, label %t2
49*9880d681SAndroid Build Coastguard Worker; CHECK: fcmp {{d[0-9]+}}, {{d[0-9]+}}
50*9880d681SAndroid Build Coastguard Worker; CHECK: b.eq .L
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Workert2:
53*9880d681SAndroid Build Coastguard Worker  %tst2 = fcmp une double %b, 0.0
54*9880d681SAndroid Build Coastguard Worker  br i1 %tst2, label %t3, label %end
55*9880d681SAndroid Build Coastguard Worker; CHECK: fcmp {{d[0-9]+}}, #0.0
56*9880d681SAndroid Build Coastguard Worker; CHECK: b.eq .L
57*9880d681SAndroid Build Coastguard Worker
58*9880d681SAndroid Build Coastguard Worker
59*9880d681SAndroid Build Coastguard Workert3:
60*9880d681SAndroid Build Coastguard Worker; This test can't be implemented with just one A64 conditional
61*9880d681SAndroid Build Coastguard Worker; branch. LLVM converts "ordered and not equal" to "unordered or
62*9880d681SAndroid Build Coastguard Worker; equal" before instruction selection, which is what we currently
63*9880d681SAndroid Build Coastguard Worker; test. Obviously, other sequences are valid.
64*9880d681SAndroid Build Coastguard Worker  %tst3 = fcmp one double %a,  %b
65*9880d681SAndroid Build Coastguard Worker  br i1 %tst3, label %t4, label %end
66*9880d681SAndroid Build Coastguard Worker; CHECK: fcmp {{d[0-9]+}}, {{d[0-9]+}}
67*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: b.eq .[[T4:LBB[0-9]+_[0-9]+]]
68*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: b.vs .[[T4]]
69*9880d681SAndroid Build Coastguard Workert4:
70*9880d681SAndroid Build Coastguard Worker  %tst4 = fcmp uge double %a, -0.0
71*9880d681SAndroid Build Coastguard Worker  br i1 %tst4, label %t5, label %end
72*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: fcmp {{d[0-9]+}}, #0.0
73*9880d681SAndroid Build Coastguard Worker; CHECK: b.mi .LBB
74*9880d681SAndroid Build Coastguard Worker
75*9880d681SAndroid Build Coastguard Workert5:
76*9880d681SAndroid Build Coastguard Worker  call void @bar(i32 0)
77*9880d681SAndroid Build Coastguard Worker  ret void
78*9880d681SAndroid Build Coastguard Workerend:
79*9880d681SAndroid Build Coastguard Worker  ret void
80*9880d681SAndroid Build Coastguard Worker
81*9880d681SAndroid Build Coastguard Worker}
82