1 ; RUN: llc -mcpu=pwr7 -mattr=+altivec -mattr=-vsx < %s | FileCheck %s 2 3 target datalayout = "e-m:e-i64:64-n32:64" 4 target triple = "powerpc64le-unknown-linux-gnu" 5 6 @g = common global ppc_fp128 0xM00000000000000000000000000000000, align 16 7 8 define void @callee(ppc_fp128 %x) { 9 entry: 10 %x.addr = alloca ppc_fp128, align 16 11 store ppc_fp128 %x, ppc_fp128* %x.addr, align 16 12 %0 = load ppc_fp128, ppc_fp128* %x.addr, align 16 13 store ppc_fp128 %0, ppc_fp128* @g, align 16 14 ret void 15 } 16 ; CHECK: @callee 17 ; CHECK: ld [[REG:[0-9]+]], .LC 18 ; CHECK: stfd 2, 8([[REG]]) 19 ; CHECK: stfd 1, 0([[REG]]) 20 ; CHECK: blr 21 22 define void @caller() { 23 entry: 24 %0 = load ppc_fp128, ppc_fp128* @g, align 16 25 call void @test(ppc_fp128 %0) 26 ret void 27 } 28 ; CHECK: @caller 29 ; CHECK: ld [[REG:[0-9]+]], .LC 30 ; CHECK: lfd 2, 8([[REG]]) 31 ; CHECK: lfd 1, 0([[REG]]) 32 ; CHECK: bl test 33 34 declare void @test(ppc_fp128) 35 36 define void @caller_const() { 37 entry: 38 call void @test(ppc_fp128 0xM3FF00000000000000000000000000000) 39 ret void 40 } 41 ; CHECK: .LCPI[[LC:[0-9]+]]_0: 42 ; CHECK: .long 1065353216 43 ; CHECK: .LCPI[[LC]]_1: 44 ; CHECK: .long 0 45 ; CHECK: @caller_const 46 ; CHECK: addi [[REG0:[0-9]+]], {{[0-9]+}}, .LCPI[[LC]]_0 47 ; CHECK: addi [[REG1:[0-9]+]], {{[0-9]+}}, .LCPI[[LC]]_1 48 ; CHECK: lfs 1, 0([[REG0]]) 49 ; CHECK: lfs 2, 0([[REG1]]) 50 ; CHECK: bl test 51 52 define ppc_fp128 @result() { 53 entry: 54 %0 = load ppc_fp128, ppc_fp128* @g, align 16 55 ret ppc_fp128 %0 56 } 57 ; CHECK: @result 58 ; CHECK: ld [[REG:[0-9]+]], .LC 59 ; CHECK: lfd 1, 0([[REG]]) 60 ; CHECK: lfd 2, 8([[REG]]) 61 ; CHECK: blr 62 63 define void @use_result() { 64 entry: 65 %call = tail call ppc_fp128 @test_result() #3 66 store ppc_fp128 %call, ppc_fp128* @g, align 16 67 ret void 68 } 69 ; CHECK: @use_result 70 ; CHECK: bl test_result 71 ; CHECK: ld [[REG:[0-9]+]], .LC 72 ; CHECK: stfd 2, 8([[REG]]) 73 ; CHECK: stfd 1, 0([[REG]]) 74 ; CHECK: blr 75 76 declare ppc_fp128 @test_result() 77 78 define void @caller_result() { 79 entry: 80 %call = tail call ppc_fp128 @test_result() 81 tail call void @test(ppc_fp128 %call) 82 ret void 83 } 84 ; CHECK: @caller_result 85 ; CHECK: bl test_result 86 ; CHECK-NEXT: nop 87 ; CHECK-NEXT: bl test 88 ; CHECK-NEXT: nop 89 90 define i128 @convert_from(ppc_fp128 %x) { 91 entry: 92 %0 = bitcast ppc_fp128 %x to i128 93 ret i128 %0 94 } 95 ; CHECK: @convert_from 96 ; CHECK: stfd 1, [[OFF1:.*]](1) 97 ; CHECK: stfd 2, [[OFF2:.*]](1) 98 ; CHECK: ld 3, [[OFF1]](1) 99 ; CHECK: ld 4, [[OFF2]](1) 100 ; CHECK: blr 101 102 define ppc_fp128 @convert_to(i128 %x) { 103 entry: 104 %0 = bitcast i128 %x to ppc_fp128 105 ret ppc_fp128 %0 106 } 107 ; CHECK: convert_to: 108 ; CHECK: std 3, [[OFF1:.*]](1) 109 ; CHECK: std 4, [[OFF2:.*]](1) 110 ; CHECK: ori 2, 2, 0 111 ; CHECK: lfd 1, [[OFF1]](1) 112 ; CHECK: lfd 2, [[OFF2]](1) 113 ; CHECK: blr 114 115 define ppc_fp128 @convert_to2(i128 %x) { 116 entry: 117 %shl = shl i128 %x, 1 118 %0 = bitcast i128 %shl to ppc_fp128 119 ret ppc_fp128 %0 120 } 121 122 ; CHECK: convert_to2: 123 ; CHECK: std 3, [[OFF1:.*]](1) 124 ; CHECK: std 5, [[OFF2:.*]](1) 125 ; CHECK: ori 2, 2, 0 126 ; CHECK: lfd 1, [[OFF1]](1) 127 ; CHECK: lfd 2, [[OFF2]](1) 128 ; CHECK: blr 129 130 define double @convert_vector(<4 x i32> %x) { 131 entry: 132 %cast = bitcast <4 x i32> %x to ppc_fp128 133 %conv = fptrunc ppc_fp128 %cast to double 134 ret double %conv 135 } 136 ; CHECK: @convert_vector 137 ; CHECK: addi [[REG:[0-9]+]], 1, [[OFF:.*]] 138 ; CHECK: stvx 2, 0, [[REG]] 139 ; CHECK: lfd 1, [[OFF]](1) 140 ; CHECK: blr 141 142 declare void @llvm.va_start(i8*) 143 144 define double @vararg(i32 %a, ...) { 145 entry: 146 %va = alloca i8*, align 8 147 %va1 = bitcast i8** %va to i8* 148 call void @llvm.va_start(i8* %va1) 149 %arg = va_arg i8** %va, ppc_fp128 150 %conv = fptrunc ppc_fp128 %arg to double 151 ret double %conv 152 } 153 ; CHECK: @vararg 154 ; CHECK: lfd 1, 0({{[0-9]+}}) 155 ; CHECK: blr 156 157