1 ; RUN: llc -verify-machineinstrs -o - %s -mtriple=aarch64-linux-gnu | FileCheck %s
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:
11 br i1 %c, label %if.else, label %if.then
15 ; CHECK-NEXT: str w0, [sp, #[[SLOT:[0-9]+]]]
16 %call1 = tail call i32 @bar()
21 ; CHECK-NEXT: str wzr, [sp, #[[SLOT]]]
22 %call2 = tail call i32 @baz()
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
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:
36 br i1 %c, label %if.else, label %if.then
40 ; CHECK-NEXT: str w0, [sp, #[[SLOT:[0-9]+]]]
41 %call1 = tail call i32 @bar()
46 ; CHECK-NEXT: str wzr, [sp, #[[SLOT]]]
47 %call2 = tail call i32 @baz()
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
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:
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]]]
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:
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