Home | History | Annotate | Download | only in PowerPC
      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: lfd 1, [[OFF1]](1)
    111 ; CHECK: lfd 2, [[OFF2]](1)
    112 ; CHECK: blr
    113 
    114 define ppc_fp128 @convert_to2(i128 %x) {
    115 entry:
    116   %shl = shl i128 %x, 1
    117   %0 = bitcast i128 %shl to ppc_fp128
    118   ret ppc_fp128 %0
    119 }
    120 
    121 ; CHECK: @convert_to
    122 ; CHECK: std 3, [[OFF1:.*]](1)
    123 ; CHECK: std 4, [[OFF2:.*]](1)
    124 ; CHECK: lfd 1, [[OFF1]](1)
    125 ; CHECK: lfd 2, [[OFF2]](1)
    126 ; CHECK: blr
    127 
    128 define double @convert_vector(<4 x i32> %x) {
    129 entry:
    130   %cast = bitcast <4 x i32> %x to ppc_fp128
    131   %conv = fptrunc ppc_fp128 %cast to double
    132   ret double %conv
    133 }
    134 ; CHECK: @convert_vector
    135 ; CHECK: addi [[REG:[0-9]+]], 1, [[OFF:.*]]
    136 ; CHECK: stvx 2, 0, [[REG]]
    137 ; CHECK: lfd 1, [[OFF]](1)
    138 ; CHECK: blr
    139 
    140 declare void @llvm.va_start(i8*)
    141 
    142 define double @vararg(i32 %a, ...) {
    143 entry:
    144   %va = alloca i8*, align 8
    145   %va1 = bitcast i8** %va to i8*
    146   call void @llvm.va_start(i8* %va1)
    147   %arg = va_arg i8** %va, ppc_fp128
    148   %conv = fptrunc ppc_fp128 %arg to double
    149   ret double %conv
    150 }
    151 ; CHECK: @vararg
    152 ; CHECK: lfd 1, 0({{[0-9]+}})
    153 ; CHECK: blr
    154 
    155