16ff31fe3SThomas Lively; RUN: llc -o - %s -asm-verbose=false -wasm-keep-registers -disable-wasm-fallthrough-return-opt -mattr=+simd128 | FileCheck %s
26ff31fe3SThomas Lively
3e81021a5SDan Gohmantarget datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
4a5908009SSam Cleggtarget triple = "wasm32-unknown-unknown"
5e81021a5SDan Gohman
6e81021a5SDan Gohman; Test that stackified IMPLICIT_DEF instructions are converted into
76ff31fe3SThomas Lively; CONST_XXX instructions to provide an explicit push.
8e81021a5SDan Gohman
96ff31fe3SThomas Lively; CHECK-LABEL: implicit_def_i32:
106ff31fe3SThomas Lively; CHECK: .LBB{{[0-9]+}}_4:{{$}}
116ff31fe3SThomas Lively; CHECK-NEXT: end_block{{$}}
126ff31fe3SThomas Lively; CHECK-NEXT: i32.const $push[[R:[0-9]+]]=, 0{{$}}
136ff31fe3SThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
146ff31fe3SThomas Lively; CHECK-NEXT: end_function{{$}}
156ff31fe3SThomas Livelydefine i32 @implicit_def_i32() {
166ff31fe3SThomas Lively  br i1 undef, label %A, label %X
17e81021a5SDan Gohman
186ff31fe3SThomas LivelyA:                                                ; preds = %0
196ff31fe3SThomas Lively  %d = icmp slt i1 0, 0
206ff31fe3SThomas Lively  br i1 %d, label %C, label %B
216ff31fe3SThomas Lively
226ff31fe3SThomas LivelyB:                                                ; preds = %A
236ff31fe3SThomas Lively  br label %C
246ff31fe3SThomas Lively
256ff31fe3SThomas LivelyC:                                                ; preds = %B, %A
266ff31fe3SThomas Lively  %h = phi i32 [ undef, %A ], [ 0, %B ]
27e81021a5SDan Gohman  br label %X
28e81021a5SDan Gohman
296ff31fe3SThomas LivelyX:                                                ; preds = %0, C
306ff31fe3SThomas Lively  %i = phi i32 [ 1, %0 ], [ %h, %C ]
316ff31fe3SThomas Lively  ret i32 %i
32e81021a5SDan Gohman}
33e81021a5SDan Gohman
346ff31fe3SThomas Lively; CHECK-LABEL: implicit_def_i64:
356ff31fe3SThomas Lively; CHECK: .LBB{{[0-9]+}}_4:{{$}}
366ff31fe3SThomas Lively; CHECK-NEXT: end_block{{$}}
376ff31fe3SThomas Lively; CHECK-NEXT: i64.const $push[[R:[0-9]+]]=, 0{{$}}
386ff31fe3SThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
396ff31fe3SThomas Lively; CHECK-NEXT: end_function{{$}}
406ff31fe3SThomas Livelydefine i64 @implicit_def_i64() {
416ff31fe3SThomas Lively  br i1 undef, label %A, label %X
426ff31fe3SThomas Lively
436ff31fe3SThomas LivelyA:                                                ; preds = %0
446ff31fe3SThomas Lively  %d = icmp slt i1 0, 0
456ff31fe3SThomas Lively  br i1 %d, label %C, label %B
466ff31fe3SThomas Lively
476ff31fe3SThomas LivelyB:                                                ; preds = %A
486ff31fe3SThomas Lively  br label %C
496ff31fe3SThomas Lively
506ff31fe3SThomas LivelyC:                                                ; preds = %B, %A
516ff31fe3SThomas Lively  %h = phi i64 [ undef, %A ], [ 0, %B ]
526ff31fe3SThomas Lively  br label %X
536ff31fe3SThomas Lively
546ff31fe3SThomas LivelyX:                                                ; preds = %0, C
556ff31fe3SThomas Lively  %i = phi i64 [ 1, %0 ], [ %h, %C ]
566ff31fe3SThomas Lively  ret i64 %i
576ff31fe3SThomas Lively}
586ff31fe3SThomas Lively
596ff31fe3SThomas Lively; CHECK-LABEL: implicit_def_f32:
606ff31fe3SThomas Lively; CHECK: .LBB{{[0-9]+}}_4:{{$}}
616ff31fe3SThomas Lively; CHECK-NEXT: end_block{{$}}
626ff31fe3SThomas Lively; CHECK-NEXT: f32.const $push[[R:[0-9]+]]=, 0x0p0{{$}}
636ff31fe3SThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
646ff31fe3SThomas Lively; CHECK-NEXT: end_function{{$}}
656ff31fe3SThomas Livelydefine float @implicit_def_f32() {
666ff31fe3SThomas Lively  br i1 undef, label %A, label %X
676ff31fe3SThomas Lively
686ff31fe3SThomas LivelyA:                                                ; preds = %0
696ff31fe3SThomas Lively  %d = icmp slt i1 0, 0
706ff31fe3SThomas Lively  br i1 %d, label %C, label %B
716ff31fe3SThomas Lively
726ff31fe3SThomas LivelyB:                                                ; preds = %A
736ff31fe3SThomas Lively  br label %C
746ff31fe3SThomas Lively
756ff31fe3SThomas LivelyC:                                                ; preds = %B, %A
766ff31fe3SThomas Lively  %h = phi float [ undef, %A ], [ 0.0, %B ]
776ff31fe3SThomas Lively  br label %X
786ff31fe3SThomas Lively
796ff31fe3SThomas LivelyX:                                                ; preds = %0, C
806ff31fe3SThomas Lively  %i = phi float [ 1.0, %0 ], [ %h, %C ]
816ff31fe3SThomas Lively  ret float %i
826ff31fe3SThomas Lively}
836ff31fe3SThomas Lively
846ff31fe3SThomas Lively; CHECK-LABEL: implicit_def_f64:
856ff31fe3SThomas Lively; CHECK: .LBB{{[0-9]+}}_4:{{$}}
866ff31fe3SThomas Lively; CHECK-NEXT: end_block{{$}}
876ff31fe3SThomas Lively; CHECK-NEXT: f64.const $push[[R:[0-9]+]]=, 0x0p0{{$}}
886ff31fe3SThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
896ff31fe3SThomas Lively; CHECK-NEXT: end_function{{$}}
906ff31fe3SThomas Livelydefine double @implicit_def_f64() {
916ff31fe3SThomas Lively  br i1 undef, label %A, label %X
926ff31fe3SThomas Lively
936ff31fe3SThomas LivelyA:                                                ; preds = %0
946ff31fe3SThomas Lively  %d = icmp slt i1 0, 0
956ff31fe3SThomas Lively  br i1 %d, label %C, label %B
966ff31fe3SThomas Lively
976ff31fe3SThomas LivelyB:                                                ; preds = %A
986ff31fe3SThomas Lively  br label %C
996ff31fe3SThomas Lively
1006ff31fe3SThomas LivelyC:                                                ; preds = %B, %A
1016ff31fe3SThomas Lively  %h = phi double [ undef, %A ], [ 0.0, %B ]
1026ff31fe3SThomas Lively  br label %X
1036ff31fe3SThomas Lively
1046ff31fe3SThomas LivelyX:                                                ; preds = %0, C
1056ff31fe3SThomas Lively  %i = phi double [ 1.0, %0 ], [ %h, %C ]
1066ff31fe3SThomas Lively  ret double %i
1076ff31fe3SThomas Lively}
1086ff31fe3SThomas Lively
1096ff31fe3SThomas Lively; CHECK-LABEL: implicit_def_v4i32:
1106ff31fe3SThomas Lively; CHECK: .LBB{{[0-9]+}}_4:{{$}}
1116ff31fe3SThomas Lively; CHECK-NEXT: end_block{{$}}
112*feb18fe9SThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 0{{$}}
113*feb18fe9SThomas Lively; CHECK-NEXT: i32x4.splat $push[[R:[0-9]+]]=, $pop[[L0]]
1146ff31fe3SThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
1156ff31fe3SThomas Lively; CHECK-NEXT: end_function{{$}}
1166ff31fe3SThomas Livelydefine <4 x i32> @implicit_def_v4i32() {
1176ff31fe3SThomas Lively  br i1 undef, label %A, label %X
1186ff31fe3SThomas Lively
1196ff31fe3SThomas LivelyA:                                                ; preds = %0
1206ff31fe3SThomas Lively  %d = icmp slt i1 0, 0
1216ff31fe3SThomas Lively  br i1 %d, label %C, label %B
1226ff31fe3SThomas Lively
1236ff31fe3SThomas LivelyB:                                                ; preds = %A
1246ff31fe3SThomas Lively  br label %C
1256ff31fe3SThomas Lively
1266ff31fe3SThomas LivelyC:                                                ; preds = %B, %A
1276ff31fe3SThomas Lively  %h = phi <4 x i32> [ undef, %A ], [ <i32 0, i32 0, i32 0, i32 0>, %B ]
1286ff31fe3SThomas Lively  br label %X
1296ff31fe3SThomas Lively
1306ff31fe3SThomas LivelyX:                                                ; preds = %0, C
1316ff31fe3SThomas Lively  %i = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %0 ], [ %h, %C ]
1326ff31fe3SThomas Lively  ret <4 x i32> %i
1336ff31fe3SThomas Lively}
134