blob: 74093aa1da49442d03644cb882bf8fe4c65cb02b [file] [log] [blame]
Nemanja Ivanovice22ebea2017-09-26 20:42:47 +00001; XFAIL: *
Nemanja Ivanovicd6f93f52017-09-22 11:50:25 +00002; The purpose of the test case is to ensure that a spill that happens during
3; intermediate calculations for a comparison performed in a GPR spills the
4; full register. Some i32 comparisons performed in GPRs use code that uses
5; the full 64-bits of the register in intermediate stages. Spilling such a value
6; as a 32-bit value is incorrect.
7; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
8; RUN: -ppc-asm-full-reg-names -mcpu=pwr8 < %s | FileCheck %s \
9; RUN: --implicit-check-not cmpw --implicit-check-not cmpd --implicit-check-not cmpl
10; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
11; RUN: -ppc-asm-full-reg-names -mcpu=pwr8 < %s | FileCheck %s \
12; RUN: --implicit-check-not cmpw --implicit-check-not cmpd --implicit-check-not cmpl
13@glob = common local_unnamed_addr global i64 0, align 8
14@.str = private unnamed_addr constant [12 x i8] c"Value = %d\0A\00", align 1
15
16; Function Attrs: noinline nounwind
17define void @call(i64 %a) local_unnamed_addr #0 {
18entry:
19 store i64 %a, i64* @glob, align 8
20 tail call void asm sideeffect "#Do Nothing", "~{memory}"()
21 ret void
22}
23
24; Function Attrs: noinline nounwind
25define signext i32 @test(i32 signext %a, i32 signext %b, i32 signext %c) local_unnamed_addr #0 {
26entry:
27 %add = add nsw i32 %b, %a
28 %sub = sub nsw i32 %add, %c
29 %conv = sext i32 %sub to i64
30 tail call void @call(i64 %conv)
31 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}"()
32 %cmp = icmp sle i32 %add, %c
33 %conv1 = zext i1 %cmp to i32
34 ret i32 %conv1
35; CHECK-LABEL: test
36; CHECK: subf r3,
37; CHECK: extsw r3,
38; CHECK: bl call
39; CHECK: sub r3,
40; CHECK: rldicl r3, r3, 1, 63
41; CHECK: std r3, [[OFF:[0-9]+]](r1)
42; CHECK: #APP
43; CHECK: ld r3, [[OFF]](r1)
44; CHECK: xori r3, r3, 1
45; CHECK: blr
46}
47
48; Function Attrs: nounwind
49define signext i32 @main() local_unnamed_addr #1 {
50entry:
51 %call = tail call signext i32 @test(i32 signext 10, i32 signext -15, i32 signext 0)
52 %call1 = tail call signext i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 signext %call)
53 ret i32 0
54}
55
56; Function Attrs: nounwind
57declare signext i32 @printf(i8* nocapture readonly, ...) local_unnamed_addr #2