Home | History | Annotate | Download | only in Mips
      1 ; RUN: llc -march=mipsel < %s | FileCheck %s
      2 
      3 define i32 @twoalloca(i32 %size) nounwind {
      4 entry:
      5 ; CHECK: subu  $[[T0:[0-9]+]], $sp, $[[SZ:[0-9]+]]
      6 ; CHECK: addu  $sp, $zero, $[[T0]]
      7 ; CHECK: addiu $[[T1:[0-9]+]], $sp, [[OFF:[0-9]+]]
      8 ; CHECK: subu  $[[T2:[0-9]+]], $sp, $[[SZ]]
      9 ; CHECK: addu  $sp, $zero, $[[T2]]
     10 ; CHECK: addiu $[[T3:[0-9]+]], $sp, [[OFF]]
     11 ; CHECK: lw    $[[T4:[0-9]+]], %call16(foo)($gp)
     12 ; CHECK: addu  $25, $zero, $[[T4]]
     13 ; CHECK: addu  $4, $zero, $[[T1]]
     14 ; CHECK: jalr  $25
     15   %tmp1 = alloca i8, i32 %size, align 4
     16   %add.ptr = getelementptr inbounds i8* %tmp1, i32 5
     17   store i8 97, i8* %add.ptr, align 1
     18   %tmp4 = alloca i8, i32 %size, align 4
     19   call void @foo2(double 1.000000e+00, double 2.000000e+00, i32 3) nounwind
     20   %call = call i32 @foo(i8* %tmp1) nounwind
     21   %call7 = call i32 @foo(i8* %tmp4) nounwind
     22   %add = add nsw i32 %call7, %call
     23   ret i32 %add
     24 }
     25 
     26 declare void @foo2(double, double, i32)
     27 
     28 declare i32 @foo(i8*)
     29 
     30 @.str = private unnamed_addr constant [22 x i8] c"%d %d %d %d %d %d %d\0A\00", align 1
     31 
     32 define i32 @alloca2(i32 %size) nounwind {
     33 entry:
     34 ; dynamic allocated stack area and $gp restore slot have the same offsets
     35 ; relative to $sp.
     36 ;
     37 ; CHECK: alloca2
     38 ; CHECK: .cprestore [[OFF:[0-9]+]]
     39 ; CHECK: subu  $[[T0:[0-9]+]], $sp, $[[SZ:[0-9]+]]
     40 ; CHECK: addu  $sp, $zero, $[[T0]]
     41 ; CHECK: addiu $[[T1:[0-9]+]], $sp, [[OFF]]
     42 
     43   %tmp1 = alloca i8, i32 %size, align 4
     44   %0 = bitcast i8* %tmp1 to i32*
     45   %cmp = icmp sgt i32 %size, 10
     46   br i1 %cmp, label %if.then, label %if.else
     47 
     48 if.then:                                          ; preds = %entry
     49 ; CHECK: addiu $4, $[[T1]], 40
     50 
     51   %add.ptr = getelementptr inbounds i8* %tmp1, i32 40
     52   %1 = bitcast i8* %add.ptr to i32*
     53   call void @foo3(i32* %1) nounwind
     54   %arrayidx15.pre = getelementptr inbounds i8* %tmp1, i32 12
     55   %.pre = bitcast i8* %arrayidx15.pre to i32*
     56   br label %if.end
     57 
     58 if.else:                                          ; preds = %entry
     59 ; CHECK: addiu $4, $[[T1]], 12
     60 
     61   %add.ptr5 = getelementptr inbounds i8* %tmp1, i32 12
     62   %2 = bitcast i8* %add.ptr5 to i32*
     63   call void @foo3(i32* %2) nounwind
     64   br label %if.end
     65 
     66 if.end:                                           ; preds = %if.else, %if.then
     67 ; CHECK: lw  $5, 0($[[T1]])
     68 ; CHECK: lw  $25, %call16(printf)
     69 
     70   %.pre-phi = phi i32* [ %2, %if.else ], [ %.pre, %if.then ]
     71   %tmp7 = load i32* %0, align 4, !tbaa !0
     72   %arrayidx9 = getelementptr inbounds i8* %tmp1, i32 4
     73   %3 = bitcast i8* %arrayidx9 to i32*
     74   %tmp10 = load i32* %3, align 4, !tbaa !0
     75   %arrayidx12 = getelementptr inbounds i8* %tmp1, i32 8
     76   %4 = bitcast i8* %arrayidx12 to i32*
     77   %tmp13 = load i32* %4, align 4, !tbaa !0
     78   %tmp16 = load i32* %.pre-phi, align 4, !tbaa !0
     79   %arrayidx18 = getelementptr inbounds i8* %tmp1, i32 16
     80   %5 = bitcast i8* %arrayidx18 to i32*
     81   %tmp19 = load i32* %5, align 4, !tbaa !0
     82   %arrayidx21 = getelementptr inbounds i8* %tmp1, i32 20
     83   %6 = bitcast i8* %arrayidx21 to i32*
     84   %tmp22 = load i32* %6, align 4, !tbaa !0
     85   %arrayidx24 = getelementptr inbounds i8* %tmp1, i32 24
     86   %7 = bitcast i8* %arrayidx24 to i32*
     87   %tmp25 = load i32* %7, align 4, !tbaa !0
     88   %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([22 x i8]* @.str, i32 0, i32 0), i32 %tmp7, i32 %tmp10, i32 %tmp13, i32 %tmp16, i32 %tmp19, i32 %tmp22, i32 %tmp25) nounwind
     89   ret i32 0
     90 }
     91 
     92 declare void @foo3(i32*)
     93 
     94 declare i32 @printf(i8* nocapture, ...) nounwind
     95 
     96 !0 = metadata !{metadata !"int", metadata !1}
     97 !1 = metadata !{metadata !"omnipotent char", metadata !2}
     98 !2 = metadata !{metadata !"Simple C/C++ TBAA", null}
     99