[PowerPC] Convert r+r instructions to r+i (pre and post RA)
[llvm-core.git] / test / CodeGen / PowerPC / fast-isel-call.ll
blob231f29e6e4d7a972059f17a236a8063b100e3c41
1 ; FIXME: FastISel currently returns false if it hits code that uses VSX
2 ; registers and with -fast-isel-abort=1 turned on the test case will then fail.
3 ; When fastisel better supports VSX fix up this test case.
5 ; RUN: llc < %s -O0 -verify-machineinstrs -mattr=-vsx -fast-isel-abort=1 -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 | FileCheck %s --check-prefix=ELF64
7 define i32 @t1(i8 signext %a) nounwind {
8   %1 = sext i8 %a to i32
9   ret i32 %1
12 define i32 @t2(i8 zeroext %a) nounwind {
13   %1 = zext i8 %a to i32
14   ret i32 %1
17 define i32 @t3(i16 signext %a) nounwind {
18   %1 = sext i16 %a to i32
19   ret i32 %1
22 define i32 @t4(i16 zeroext %a) nounwind {
23   %1 = zext i16 %a to i32
24   ret i32 %1
27 define void @foo(i8 %a, i16 %b) nounwind {
28 ; ELF64: foo
29   %1 = call i32 @t1(i8 signext %a)
30 ; ELF64: extsb
31   %2 = call i32 @t2(i8 zeroext %a)
32 ; ELF64: clrldi {{[0-9]+}}, {{[0-9]+}}, 56
33   %3 = call i32 @t3(i16 signext %b)
34 ; ELF64: extsh
35   %4 = call i32 @t4(i16 zeroext %b)
36 ; ELF64: clrldi {{[0-9]+}}, {{[0-9]+}}, 48
38 ;; A few test to check materialization
39   %5 = call i32 @t2(i8 zeroext 255)
40 ; ELF64: li 3, 255
41 ; ELF64-NOT: clrldi
42   %6 = call i32 @t4(i16 zeroext 65535)
43 ; ELF64: lis 3, 0
44 ; ELF64: ori 3, 3, 65535
45 ; ELF64: clrldi 3, 3, 48
46 ; ELF64: bl t4
47   ret void
50 define void @foo2() nounwind {
51   %1 = call signext i16 @t5()
52   %2 = call zeroext i16 @t6()
53   %3 = call signext i8 @t7()
54   %4 = call zeroext i8 @t8()
55   ret void
58 declare signext i16 @t5();
59 declare zeroext i16 @t6();
60 declare signext i8 @t7();
61 declare zeroext i8 @t8();
63 define i32 @t10(i32 %argc, i8** nocapture %argv) nounwind {
64 entry:
65 ; ELF64: t10
66   %call = call i32 @bar(i8 zeroext 0, i8 zeroext -8, i8 zeroext -69, i8 zeroext 28, i8 zeroext 40, i8 zeroext -70)
67 ; ELF64: li 3, 0
68 ; ELF64: li 4, 248
69 ; ELF64: li 5, 187
70 ; ELF64: li 6, 28
71 ; ELF64: li 7, 40
72 ; ELF64: li 8, 186
73 ; ELF64-NOT: clrldi
74 ; ELF64: bl bar
75   ret i32 0
78 declare i32 @bar(i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext)
80 define i32 @bar0(i32 %i) nounwind {
81   ret i32 0
84 ; Function pointers are not yet implemented.
85 ;define void @foo3() uwtable {
86 ;  %fptr = alloca i32 (i32)*, align 8
87 ;  store i32 (i32)* @bar0, i32 (i32)** %fptr, align 8
88 ;  %1 = load i32 (i32)*, i32 (i32)** %fptr, align 8
89 ;  %call = call i32 %1(i32 0)
90 ;  ret void
93 ; Intrinsic calls not yet implemented, and udiv isn't one for PPC anyway.
94 ;define i32 @LibCall(i32 %a, i32 %b) {
95 ;entry:
96 ;        %tmp1 = udiv i32 %a, %b         ; <i32> [#uses=1]
97 ;        ret i32 %tmp1
100 declare void @float_foo(float %f)
102 define void @float_const() nounwind {
103 entry:
104 ; ELF64: float_const
105   call void @float_foo(float 0x401C666660000000)
106 ; ELF64: addis [[REG:[0-9]+]], 2, .LCPI[[SUF:[0-9_]+]]@toc@ha
107 ; ELF64: lfs 1, .LCPI[[SUF]]@toc@l([[REG]])
108   ret void
111 define void @float_reg(float %dummy, float %f) nounwind {
112 entry:
113 ; ELF64: float_reg
114   call void @float_foo(float %f)
115 ; ELF64: fmr 1, 2
116   ret void
119 declare void @double_foo(double %d)
121 define void @double_const() nounwind {
122 entry:
123 ; ELF64: double_const
124   call void @double_foo(double 0x1397723CCABD0000401C666660000000)
125 ; ELF64: addis [[REG2:[0-9]+]], 2, .LCPI[[SUF2:[0-9_]+]]@toc@ha
126 ; ELF64: lfd 1, .LCPI[[SUF2]]@toc@l([[REG2]])
127   ret void
130 define void @double_reg(double %dummy, double %d) nounwind {
131 entry:
132 ; ELF64: double_reg
133   call void @double_foo(double %d)
134 ; ELF64: fmr 1, 2
135   ret void