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:
10ef9d6aeaSHeejin Ahn; CHECK:      i32.const $push{{[0-9]+}}=, 0{{$}}
11ef9d6aeaSHeejin Ahn; CHECK:      i32.const $push{{[0-9]+}}=, 0{{$}}
12ef9d6aeaSHeejin Ahn; CHECK:      i32.const $push[[R:[0-9]+]]=, 0{{$}}
136ff31fe3SThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
146ff31fe3SThomas Livelydefine i32 @implicit_def_i32() {
156ff31fe3SThomas Lively  br i1 undef, label %A, label %X
16e81021a5SDan Gohman
176ff31fe3SThomas LivelyA:                                                ; preds = %0
186ff31fe3SThomas Lively  %d = icmp slt i1 0, 0
196ff31fe3SThomas Lively  br i1 %d, label %C, label %B
206ff31fe3SThomas Lively
216ff31fe3SThomas LivelyB:                                                ; preds = %A
226ff31fe3SThomas Lively  br label %C
236ff31fe3SThomas Lively
246ff31fe3SThomas LivelyC:                                                ; preds = %B, %A
256ff31fe3SThomas Lively  %h = phi i32 [ undef, %A ], [ 0, %B ]
26e81021a5SDan Gohman  br label %X
27e81021a5SDan Gohman
286ff31fe3SThomas LivelyX:                                                ; preds = %0, C
296ff31fe3SThomas Lively  %i = phi i32 [ 1, %0 ], [ %h, %C ]
306ff31fe3SThomas Lively  ret i32 %i
31e81021a5SDan Gohman}
32e81021a5SDan Gohman
336ff31fe3SThomas Lively; CHECK-LABEL: implicit_def_i64:
34ef9d6aeaSHeejin Ahn; CHECK:      i64.const $push[[R:[0-9]+]]=, 0{{$}}
356ff31fe3SThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
366ff31fe3SThomas Livelydefine i64 @implicit_def_i64() {
376ff31fe3SThomas Lively  br i1 undef, label %A, label %X
386ff31fe3SThomas Lively
396ff31fe3SThomas LivelyA:                                                ; preds = %0
406ff31fe3SThomas Lively  %d = icmp slt i1 0, 0
416ff31fe3SThomas Lively  br i1 %d, label %C, label %B
426ff31fe3SThomas Lively
436ff31fe3SThomas LivelyB:                                                ; preds = %A
446ff31fe3SThomas Lively  br label %C
456ff31fe3SThomas Lively
466ff31fe3SThomas LivelyC:                                                ; preds = %B, %A
476ff31fe3SThomas Lively  %h = phi i64 [ undef, %A ], [ 0, %B ]
486ff31fe3SThomas Lively  br label %X
496ff31fe3SThomas Lively
506ff31fe3SThomas LivelyX:                                                ; preds = %0, C
516ff31fe3SThomas Lively  %i = phi i64 [ 1, %0 ], [ %h, %C ]
526ff31fe3SThomas Lively  ret i64 %i
536ff31fe3SThomas Lively}
546ff31fe3SThomas Lively
556ff31fe3SThomas Lively; CHECK-LABEL: implicit_def_f32:
56ef9d6aeaSHeejin Ahn; CHECK:      f32.const $push[[R:[0-9]+]]=, 0x0p0{{$}}
576ff31fe3SThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
586ff31fe3SThomas Livelydefine float @implicit_def_f32() {
596ff31fe3SThomas Lively  br i1 undef, label %A, label %X
606ff31fe3SThomas Lively
616ff31fe3SThomas LivelyA:                                                ; preds = %0
626ff31fe3SThomas Lively  %d = icmp slt i1 0, 0
636ff31fe3SThomas Lively  br i1 %d, label %C, label %B
646ff31fe3SThomas Lively
656ff31fe3SThomas LivelyB:                                                ; preds = %A
666ff31fe3SThomas Lively  br label %C
676ff31fe3SThomas Lively
686ff31fe3SThomas LivelyC:                                                ; preds = %B, %A
696ff31fe3SThomas Lively  %h = phi float [ undef, %A ], [ 0.0, %B ]
706ff31fe3SThomas Lively  br label %X
716ff31fe3SThomas Lively
726ff31fe3SThomas LivelyX:                                                ; preds = %0, C
736ff31fe3SThomas Lively  %i = phi float [ 1.0, %0 ], [ %h, %C ]
746ff31fe3SThomas Lively  ret float %i
756ff31fe3SThomas Lively}
766ff31fe3SThomas Lively
776ff31fe3SThomas Lively; CHECK-LABEL: implicit_def_f64:
78ef9d6aeaSHeejin Ahn; CHECK:      f64.const $push[[R:[0-9]+]]=, 0x0p0{{$}}
796ff31fe3SThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
806ff31fe3SThomas Livelydefine double @implicit_def_f64() {
816ff31fe3SThomas Lively  br i1 undef, label %A, label %X
826ff31fe3SThomas Lively
836ff31fe3SThomas LivelyA:                                                ; preds = %0
846ff31fe3SThomas Lively  %d = icmp slt i1 0, 0
856ff31fe3SThomas Lively  br i1 %d, label %C, label %B
866ff31fe3SThomas Lively
876ff31fe3SThomas LivelyB:                                                ; preds = %A
886ff31fe3SThomas Lively  br label %C
896ff31fe3SThomas Lively
906ff31fe3SThomas LivelyC:                                                ; preds = %B, %A
916ff31fe3SThomas Lively  %h = phi double [ undef, %A ], [ 0.0, %B ]
926ff31fe3SThomas Lively  br label %X
936ff31fe3SThomas Lively
946ff31fe3SThomas LivelyX:                                                ; preds = %0, C
956ff31fe3SThomas Lively  %i = phi double [ 1.0, %0 ], [ %h, %C ]
966ff31fe3SThomas Lively  ret double %i
976ff31fe3SThomas Lively}
986ff31fe3SThomas Lively
996ff31fe3SThomas Lively; CHECK-LABEL: implicit_def_v4i32:
100*e657c84fSThomas Lively; CHECK:      v128.const $push[[R:[0-9]+]]=, 0, 0{{$}}
1016ff31fe3SThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
1026ff31fe3SThomas Livelydefine <4 x i32> @implicit_def_v4i32() {
1036ff31fe3SThomas Lively  br i1 undef, label %A, label %X
1046ff31fe3SThomas Lively
1056ff31fe3SThomas LivelyA:                                                ; preds = %0
1066ff31fe3SThomas Lively  %d = icmp slt i1 0, 0
1076ff31fe3SThomas Lively  br i1 %d, label %C, label %B
1086ff31fe3SThomas Lively
1096ff31fe3SThomas LivelyB:                                                ; preds = %A
1106ff31fe3SThomas Lively  br label %C
1116ff31fe3SThomas Lively
1126ff31fe3SThomas LivelyC:                                                ; preds = %B, %A
1136ff31fe3SThomas Lively  %h = phi <4 x i32> [ undef, %A ], [ <i32 0, i32 0, i32 0, i32 0>, %B ]
1146ff31fe3SThomas Lively  br label %X
1156ff31fe3SThomas Lively
1166ff31fe3SThomas LivelyX:                                                ; preds = %0, C
1176ff31fe3SThomas Lively  %i = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %0 ], [ %h, %C ]
1186ff31fe3SThomas Lively  ret <4 x i32> %i
1196ff31fe3SThomas Lively}
120