1; The purpose of the test case is to ensure that a spill that happens during
2; intermediate calculations for a comparison performed in a GPR spills the
3; full register. Some i32 comparisons performed in GPRs use code that uses
4; the full 64-bits of the register in intermediate stages. Spilling such a value
5; as a 32-bit value is incorrect.
6; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
7; RUN:   -ppc-gpr-icmps=all -ppc-asm-full-reg-names -mcpu=pwr8 < %s | FileCheck %s \
8; RUN:  --implicit-check-not cmpw --implicit-check-not cmpd --implicit-check-not cmpl
9; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
10; RUN:   -ppc-gpr-icmps=all -ppc-asm-full-reg-names -mcpu=pwr8 < %s | FileCheck %s \
11; RUN:  --implicit-check-not cmpw --implicit-check-not cmpd --implicit-check-not cmpl
12; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
13; RUN:     -ppc-asm-full-reg-names -mcpu=pwr10 < %s | \
14; RUN:     FileCheck %s --check-prefix=CHECK-P10
15; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
16; RUN:     -ppc-asm-full-reg-names -mcpu=pwr10 < %s | \
17; RUN:     FileCheck %s --check-prefix=CHECK-P10
18@glob = local_unnamed_addr global i64 0, align 8
19@.str = private unnamed_addr constant [12 x i8] c"Value = %d\0A\00", align 1
20
21; Function Attrs: noinline nounwind
22define void @call(i64 %a) local_unnamed_addr #0 {
23entry:
24  store i64 %a, i64* @glob, align 8
25  tail call void asm sideeffect "#Do Nothing", "~{memory}"()
26  ret void
27}
28
29; Function Attrs: noinline nounwind
30define signext i32 @test(i32 signext %a, i32 signext %b, i32 signext %c) local_unnamed_addr #0 {
31entry:
32  %add = add nsw i32 %b, %a
33  %sub = sub nsw i32 %add, %c
34  %conv = sext i32 %sub to i64
35  tail call void @call(i64 %conv)
36  tail call void asm sideeffect "#Do Nothing", "~{r0},~{r3},~{r4},~{r5},~{r6},~{r7},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{r16},~{r17},~{r18},~{r19},~{r20},~{r21},~{r22},~{r23},~{r24},~{r25},~{r26},~{r27},~{r28},~{r29},~{r30},~{r31}"()
37  %cmp = icmp sle i32 %add, %c
38  %conv1 = zext i1 %cmp to i32
39  ret i32 %conv1
40; CHECK-LABEL: test
41; CHECK: sub r3,
42; CHECK: extsw r3,
43; CHECK: bl call
44; CHECK: sub r3,
45; CHECK: rldicl r3, r3, 1, 63
46; CHECK: std r3, [[OFF:[0-9]+]](r1)
47; CHECK: #APP
48; CHECK: ld r3, [[OFF]](r1)
49; CHECK: xori r3, r3, 1
50; CHECK: blr
51
52; CHECK-P10-LABEL: test
53; CHECK-P10: sub r3,
54; CHECK-P10: extsw r3,
55; CHECK-P10: bl call
56; CHECK-P10: cmpw r29, r30
57; CHECK-P10: #APP
58; CHECK-P10: setbcr r3, gt
59; CHECK-P10: blr
60}
61
62; Function Attrs: nounwind
63define signext i32 @main() local_unnamed_addr #1 {
64entry:
65  %call = tail call signext i32 @test(i32 signext 10, i32 signext -15, i32 signext 0)
66  %call1 = tail call signext i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 signext %call)
67  ret i32 0
68}
69
70; Function Attrs: nounwind
71declare signext i32 @printf(i8* nocapture readonly, ...) local_unnamed_addr #2
72