1; RUN: llc -o - %s -asm-verbose=false -wasm-keep-registers -disable-wasm-fallthrough-return-opt -mattr=+simd128 | FileCheck %s
2
3target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
4target triple = "wasm32-unknown-unknown"
5
6; Test that stackified IMPLICIT_DEF instructions are converted into
7; CONST_XXX instructions to provide an explicit push.
8
9; CHECK-LABEL: implicit_def_i32:
10; CHECK:      i32.const $push{{[0-9]+}}=, 0{{$}}
11; CHECK:      i32.const $push{{[0-9]+}}=, 0{{$}}
12; CHECK:      i32.const $push[[R:[0-9]+]]=, 0{{$}}
13; CHECK-NEXT: return $pop[[R]]{{$}}
14define i32 @implicit_def_i32() {
15  br i1 undef, label %A, label %X
16
17A:                                                ; preds = %0
18  %d = icmp slt i1 0, 0
19  br i1 %d, label %C, label %B
20
21B:                                                ; preds = %A
22  br label %C
23
24C:                                                ; preds = %B, %A
25  %h = phi i32 [ undef, %A ], [ 0, %B ]
26  br label %X
27
28X:                                                ; preds = %0, C
29  %i = phi i32 [ 1, %0 ], [ %h, %C ]
30  ret i32 %i
31}
32
33; CHECK-LABEL: implicit_def_i64:
34; CHECK:      i64.const $push[[R:[0-9]+]]=, 0{{$}}
35; CHECK-NEXT: return $pop[[R]]{{$}}
36define i64 @implicit_def_i64() {
37  br i1 undef, label %A, label %X
38
39A:                                                ; preds = %0
40  %d = icmp slt i1 0, 0
41  br i1 %d, label %C, label %B
42
43B:                                                ; preds = %A
44  br label %C
45
46C:                                                ; preds = %B, %A
47  %h = phi i64 [ undef, %A ], [ 0, %B ]
48  br label %X
49
50X:                                                ; preds = %0, C
51  %i = phi i64 [ 1, %0 ], [ %h, %C ]
52  ret i64 %i
53}
54
55; CHECK-LABEL: implicit_def_f32:
56; CHECK:      f32.const $push[[R:[0-9]+]]=, 0x0p0{{$}}
57; CHECK-NEXT: return $pop[[R]]{{$}}
58define float @implicit_def_f32() {
59  br i1 undef, label %A, label %X
60
61A:                                                ; preds = %0
62  %d = icmp slt i1 0, 0
63  br i1 %d, label %C, label %B
64
65B:                                                ; preds = %A
66  br label %C
67
68C:                                                ; preds = %B, %A
69  %h = phi float [ undef, %A ], [ 0.0, %B ]
70  br label %X
71
72X:                                                ; preds = %0, C
73  %i = phi float [ 1.0, %0 ], [ %h, %C ]
74  ret float %i
75}
76
77; CHECK-LABEL: implicit_def_f64:
78; CHECK:      f64.const $push[[R:[0-9]+]]=, 0x0p0{{$}}
79; CHECK-NEXT: return $pop[[R]]{{$}}
80define double @implicit_def_f64() {
81  br i1 undef, label %A, label %X
82
83A:                                                ; preds = %0
84  %d = icmp slt i1 0, 0
85  br i1 %d, label %C, label %B
86
87B:                                                ; preds = %A
88  br label %C
89
90C:                                                ; preds = %B, %A
91  %h = phi double [ undef, %A ], [ 0.0, %B ]
92  br label %X
93
94X:                                                ; preds = %0, C
95  %i = phi double [ 1.0, %0 ], [ %h, %C ]
96  ret double %i
97}
98
99; CHECK-LABEL: implicit_def_v4i32:
100; CHECK:      i32.const $push{{[0-9]+}}=, 0{{$}}
101; CHECK:      i32.const $push{{[0-9]+}}=, 0{{$}}
102; CHECK:      i32.const $push[[L0:[0-9]+]]=, 0{{$}}
103; CHECK-NEXT: i32x4.splat $push[[R:[0-9]+]]=, $pop[[L0]]
104; CHECK-NEXT: return $pop[[R]]{{$}}
105define <4 x i32> @implicit_def_v4i32() {
106  br i1 undef, label %A, label %X
107
108A:                                                ; preds = %0
109  %d = icmp slt i1 0, 0
110  br i1 %d, label %C, label %B
111
112B:                                                ; preds = %A
113  br label %C
114
115C:                                                ; preds = %B, %A
116  %h = phi <4 x i32> [ undef, %A ], [ <i32 0, i32 0, i32 0, i32 0>, %B ]
117  br label %X
118
119X:                                                ; preds = %0, C
120  %i = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %0 ], [ %h, %C ]
121  ret <4 x i32> %i
122}
123