xref: /aosp_15_r20/external/llvm/test/CodeGen/PowerPC/cc.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mcpu=pwr7 < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Workertarget datalayout = "E-m:e-i64:64-n32:64"
3*9880d681SAndroid Build Coastguard Workertarget triple = "powerpc64-unknown-linux-gnu"
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Workerdefine i64 @test1(i64 %a, i64 %b) {
6*9880d681SAndroid Build Coastguard Workerentry:
7*9880d681SAndroid Build Coastguard Worker  %c = icmp eq i64 %a, %b
8*9880d681SAndroid Build Coastguard Worker  br label %foo
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Workerfoo:
11*9880d681SAndroid Build Coastguard Worker  call { i64, i64 } asm sideeffect "sc", "={r0},={r3},{r0},~{cr0},~{cr1},~{cr2},~{cr3},~{cr4},~{cr5},~{cr6},~{cr7}" (i64 %a)
12*9880d681SAndroid Build Coastguard Worker  br i1 %c, label %bar, label %end
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Workerbar:
15*9880d681SAndroid Build Coastguard Worker  ret i64 %b
16*9880d681SAndroid Build Coastguard Worker
17*9880d681SAndroid Build Coastguard Workerend:
18*9880d681SAndroid Build Coastguard Worker  ret i64 %a
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test1
21*9880d681SAndroid Build Coastguard Worker; CHECK: mfcr [[REG1:[0-9]+]]
22*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: cmpd
23*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: mfocrf [[REG2:[0-9]+]],
24*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: stw [[REG1]], 8(1)
25*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: stw [[REG2]], -4(1)
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Worker; CHECK: sc
28*9880d681SAndroid Build Coastguard Worker; CHECK: lwz [[REG3:[0-9]+]], -4(1)
29*9880d681SAndroid Build Coastguard Worker; CHECK: mtocrf 128, [[REG3]]
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Worker; CHECK: lwz [[REG4:[0-9]+]], 8(1)
32*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: mtocrf 32, [[REG4]]
33*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: mtocrf 16, [[REG4]]
34*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: mtocrf 8, [[REG4]]
35*9880d681SAndroid Build Coastguard Worker; CHECK: blr
36*9880d681SAndroid Build Coastguard Worker}
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Workerdefine i64 @test2(i64 %a, i64 %b) {
39*9880d681SAndroid Build Coastguard Workerentry:
40*9880d681SAndroid Build Coastguard Worker  %c = icmp eq i64 %a, %b
41*9880d681SAndroid Build Coastguard Worker  br label %foo
42*9880d681SAndroid Build Coastguard Worker
43*9880d681SAndroid Build Coastguard Workerfoo:
44*9880d681SAndroid Build Coastguard Worker  call { i64, i64 } asm sideeffect "sc", "={r0},={r3},{r0},~{cc},~{cr1},~{cr2},~{cr3},~{cr4},~{cr5},~{cr6},~{cr7}" (i64 %a)
45*9880d681SAndroid Build Coastguard Worker  br i1 %c, label %bar, label %end
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Workerbar:
48*9880d681SAndroid Build Coastguard Worker  ret i64 %b
49*9880d681SAndroid Build Coastguard Worker
50*9880d681SAndroid Build Coastguard Workerend:
51*9880d681SAndroid Build Coastguard Worker  ret i64 %a
52*9880d681SAndroid Build Coastguard Worker
53*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test2
54*9880d681SAndroid Build Coastguard Worker; CHECK: mfcr [[REG1:[0-9]+]]
55*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: cmpd
56*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: mfocrf [[REG2:[0-9]+]],
57*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: stw [[REG1]], 8(1)
58*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: stw [[REG2]], -4(1)
59*9880d681SAndroid Build Coastguard Worker
60*9880d681SAndroid Build Coastguard Worker; CHECK: sc
61*9880d681SAndroid Build Coastguard Worker; CHECK: lwz [[REG3:[0-9]+]], -4(1)
62*9880d681SAndroid Build Coastguard Worker; CHECK: mtocrf 128, [[REG3]]
63*9880d681SAndroid Build Coastguard Worker
64*9880d681SAndroid Build Coastguard Worker; CHECK: lwz [[REG4:[0-9]+]], 8(1)
65*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: mtocrf 32, [[REG4]]
66*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: mtocrf 16, [[REG4]]
67*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: mtocrf 8, [[REG4]]
68*9880d681SAndroid Build Coastguard Worker; CHECK: blr
69*9880d681SAndroid Build Coastguard Worker}
70*9880d681SAndroid Build Coastguard Worker
71