xref: /llvm-project/llvm/test/CodeGen/PowerPC/ppc-disable-non-volatile-cr.ll (revision 5403c59c608c08c8ecd4303763f08eb046eb5e4d)
1; Note: Test option to disable use of non-volatile CR to avoid CR spilling in prologue.
2; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -ppc-disable-non-volatile-cr\
3; RUN:     -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | FileCheck --check-prefix=CHECK-DISABLE %s
4; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu\
5; RUN:     -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | FileCheck --check-prefix=CHECK-ENABLE %s
6
7; Function Attrs: nounwind
8define dso_local signext i32 @DisableNonVolatileCR(i32 signext %a, i32 signext %b) {
9; CHECK-DISABLE-LABEL: DisableNonVolatileCR:
10; CHECK-DISABLE:       # %bb.0: # %entry
11; CHECK-DISABLE-NOT:    mfocrf {{r[0-9]+}}
12; CHECK-DISABLE-NOT:    stw {{r[0-9]+}}
13; CHECK-DISABLE:        stdu r1
14; CHECK-DISABLE-DAG:    mfocrf [[REG2:r[0-9]+]]
15; CHECK-DISABLE-DAG:    stw [[REG2]]
16; CHECK-DISABLE:        # %bb.1: # %if.then
17;
18; CHECK-ENABLE-LABEL: DisableNonVolatileCR:
19; CHECK-ENABLE:       # %bb.0: # %entry
20; CHECK-ENABLE-DAG:    mfocrf [[REG1:r[0-9]+]]
21; CHECK-ENABLE-DAG:    stw [[REG1]]
22; CHECK-ENABLE:        stdu r1
23; CHECK-ENABLE-NOT:    mfocrf {{r[0-9]+}}
24; CHECK-ENABLE-NOT:    stw {{r[0-9]+}}
25; CHECK-ENABLE:        # %bb.1: # %if.then
26
27entry:
28  %cmp = icmp slt i32 %a, %b
29  br i1 %cmp, label %if.then, label %if.else
30
31if.then:                                          ; preds = %entry
32  tail call void @fa()
33  br label %if.end
34
35if.else:                                          ; preds = %entry
36  tail call void @fb()
37  br label %if.end
38
39if.end:                                           ; preds = %if.else, %if.then
40  %conv = zext i1 %cmp to i32
41  %call = tail call signext i32 @callee(i32 signext %conv)
42  ret i32 %call
43}
44
45declare void @fa(...)
46declare void @fb(...)
47declare signext i32 @callee(i32 signext)
48