Home | History | Annotate | Download | only in AArch64
      1 ; RUN: llc -verify-machineinstrs -o - %s -mtriple=aarch64-linux-gnu | FileCheck %s
      2 
      3 declare i32 @bar()
      4 declare i32 @baz()
      5 
      6 ; Check that the spill of the zero value gets stored directly instead
      7 ; of being copied from wzr and then stored.
      8 define i32 @test_zr_spill_fold1(i1 %c) {
      9 ; CHECK-LABEL: test_zr_spill_fold1:
     10 entry:
     11   br i1 %c, label %if.else, label %if.then
     12 
     13 if.else:
     14 ; CHECK: bl bar
     15 ; CHECK-NEXT: str w0, [sp, #[[SLOT:[0-9]+]]]
     16   %call1 = tail call i32 @bar()
     17   br label %if.end
     18 
     19 if.then:
     20 ; CHECK: bl baz
     21 ; CHECK-NEXT: str wzr, [sp, #[[SLOT]]]
     22   %call2 = tail call i32 @baz()
     23   br label %if.end
     24 
     25 if.end:
     26   %x.0 = phi i32 [ 0, %if.then ], [ %call1, %if.else ]
     27   call void asm sideeffect "", "~{x0},~{x1},~{x2},~{x3},~{x4},~{x5},~{x6},~{x7},~{x8},~{x9},~{x10},~{x11},~{x12},~{x13},~{x14},~{x15},~{x16},~{x17},~{x18},~{x19},~{x20},~{x21},~{x22},~{x23},~{x24},~{x25},~{x26},~{x27},~{x28},~{fp},~{lr},~{sp}"() nounwind
     28   ret i32 %x.0
     29 }
     30 
     31 ; Similar to test_zr_spill_fold1, but with mis-matched register
     32 ; class between %x.0 and the 0 from %if.then.
     33 define i32 @test_zr_spill_fold2(i1 %c) {
     34 ; CHECK-LABEL: test_zr_spill_fold2:
     35 entry:
     36   br i1 %c, label %if.else, label %if.then
     37 
     38 if.else:
     39 ; CHECK: bl bar
     40 ; CHECK-NEXT: str w0, [sp, #[[SLOT:[0-9]+]]]
     41   %call1 = tail call i32 @bar()
     42   br label %if.end
     43 
     44 if.then:
     45 ; CHECK: bl baz
     46 ; CHECK-NEXT: str wzr, [sp, #[[SLOT]]]
     47   %call2 = tail call i32 @baz()
     48   br label %if.end
     49 
     50 if.end:
     51   %x.0 = phi i32 [ 0, %if.then ], [ %call1, %if.else ]
     52   call void asm sideeffect "", "~{x0},~{x1},~{x2},~{x3},~{x4},~{x5},~{x6},~{x7},~{x8},~{x9},~{x10},~{x11},~{x12},~{x13},~{x14},~{x15},~{x16},~{x17},~{x18},~{x19},~{x20},~{x21},~{x22},~{x23},~{x24},~{x25},~{x26},~{x27},~{x28},~{fp},~{lr},~{sp}"() nounwind
     53   %x.1 = add i32 %x.0, 1
     54   ret i32 %x.1
     55 }
     56 
     57 ; Similar to test_zr_spill_fold1, but with a cross register-class copy feeding a spill store.
     58 define float @test_cross_spill_fold(i32 %v) {
     59 ; CHECK-LABEL: test_cross_spill_fold:
     60 entry:
     61 ; CHECK: str w0, [sp, #[[SLOT:[0-9]+]]]
     62   %v.f = bitcast i32 %v to float
     63   call void asm sideeffect "", "~{x0},~{x1},~{x2},~{x3},~{x4},~{x5},~{x6},~{x7},~{x8},~{x9},~{x10},~{x11},~{x12},~{x13},~{x14},~{x15},~{x16},~{x17},~{x18},~{x19},~{x20},~{x21},~{x22},~{x23},~{x24},~{x25},~{x26},~{x27},~{x28},~{fp},~{lr},~{sp},~{s0},~{s1},~{s2},~{s3},~{s4},~{s5},~{s6},~{s7},~{s8},~{s9},~{s10},~{s11},~{s12},~{s13},~{s14},~{s15},~{s16},~{s17},~{s18},~{s19},~{s20},~{s21},~{s22},~{s23},~{s24},~{s25},~{s26},~{s27},~{s28},~{s29},~{s30},~{s31}"() nounwind
     64 ; CHECK: ldr s0, [sp, #[[SLOT]]]
     65   ret float %v.f
     66 }
     67 
     68 ; Similar to test_cross_spill_fold, but with a cross register-class copy fed by a refill load.
     69 define float @test_cross_spill_fold2(i32 %v) {
     70 ; CHECK-LABEL: test_cross_spill_fold2:
     71 entry:
     72 ; CHECK: str w0, [sp, #[[SLOT:[0-9]+]]]
     73   call void asm sideeffect "", "~{x0},~{x1},~{x2},~{x3},~{x4},~{x5},~{x6},~{x7},~{x8},~{x9},~{x10},~{x11},~{x12},~{x13},~{x14},~{x15},~{x16},~{x17},~{x18},~{x19},~{x20},~{x21},~{x22},~{x23},~{x24},~{x25},~{x26},~{x27},~{x28},~{fp},~{lr},~{sp},~{s0},~{s1},~{s2},~{s3},~{s4},~{s5},~{s6},~{s7},~{s8},~{s9},~{s10},~{s11},~{s12},~{s13},~{s14},~{s15},~{s16},~{s17},~{s18},~{s19},~{s20},~{s21},~{s22},~{s23},~{s24},~{s25},~{s26},~{s27},~{s28},~{s29},~{s30},~{s31}"() nounwind
     74 ; CHECK: ldr s0, [sp, #[[SLOT]]]
     75   %v.f = bitcast i32 %v to float
     76   ret float %v.f
     77 }
     78 
     79