xref: /llvm-project/llvm/test/CodeGen/WebAssembly/implicit-def.ll (revision 122b0220fd45ee71acda912b0b712bb8edb6ba46)
16ff31fe3SThomas Lively; RUN: llc -o - %s -asm-verbose=false -wasm-keep-registers -disable-wasm-fallthrough-return-opt -mattr=+simd128 | FileCheck %s
26ff31fe3SThomas Lively
3a5908009SSam Cleggtarget triple = "wasm32-unknown-unknown"
4e81021a5SDan Gohman
5e81021a5SDan Gohman; Test that stackified IMPLICIT_DEF instructions are converted into
66ff31fe3SThomas Lively; CONST_XXX instructions to provide an explicit push.
7e81021a5SDan Gohman
86ff31fe3SThomas Lively; CHECK-LABEL: implicit_def_i32:
9ef9d6aeaSHeejin Ahn; CHECK:      i32.const $push{{[0-9]+}}=, 0{{$}}
10ef9d6aeaSHeejin Ahn; CHECK:      i32.const $push{{[0-9]+}}=, 0{{$}}
11ef9d6aeaSHeejin Ahn; CHECK:      i32.const $push[[R:[0-9]+]]=, 0{{$}}
126ff31fe3SThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
136ff31fe3SThomas Livelydefine i32 @implicit_def_i32() {
146ff31fe3SThomas Lively  br i1 undef, label %A, label %X
15e81021a5SDan Gohman
166ff31fe3SThomas LivelyA:                                                ; preds = %0
176ff31fe3SThomas Lively  %d = icmp slt i1 0, 0
186ff31fe3SThomas Lively  br i1 %d, label %C, label %B
196ff31fe3SThomas Lively
206ff31fe3SThomas LivelyB:                                                ; preds = %A
216ff31fe3SThomas Lively  br label %C
226ff31fe3SThomas Lively
236ff31fe3SThomas LivelyC:                                                ; preds = %B, %A
246ff31fe3SThomas Lively  %h = phi i32 [ undef, %A ], [ 0, %B ]
25e81021a5SDan Gohman  br label %X
26e81021a5SDan Gohman
276ff31fe3SThomas LivelyX:                                                ; preds = %0, C
286ff31fe3SThomas Lively  %i = phi i32 [ 1, %0 ], [ %h, %C ]
296ff31fe3SThomas Lively  ret i32 %i
30e81021a5SDan Gohman}
31e81021a5SDan Gohman
326ff31fe3SThomas Lively; CHECK-LABEL: implicit_def_i64:
33ef9d6aeaSHeejin Ahn; CHECK:      i64.const $push[[R:[0-9]+]]=, 0{{$}}
346ff31fe3SThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
356ff31fe3SThomas Livelydefine i64 @implicit_def_i64() {
366ff31fe3SThomas Lively  br i1 undef, label %A, label %X
376ff31fe3SThomas Lively
386ff31fe3SThomas LivelyA:                                                ; preds = %0
396ff31fe3SThomas Lively  %d = icmp slt i1 0, 0
406ff31fe3SThomas Lively  br i1 %d, label %C, label %B
416ff31fe3SThomas Lively
426ff31fe3SThomas LivelyB:                                                ; preds = %A
436ff31fe3SThomas Lively  br label %C
446ff31fe3SThomas Lively
456ff31fe3SThomas LivelyC:                                                ; preds = %B, %A
466ff31fe3SThomas Lively  %h = phi i64 [ undef, %A ], [ 0, %B ]
476ff31fe3SThomas Lively  br label %X
486ff31fe3SThomas Lively
496ff31fe3SThomas LivelyX:                                                ; preds = %0, C
506ff31fe3SThomas Lively  %i = phi i64 [ 1, %0 ], [ %h, %C ]
516ff31fe3SThomas Lively  ret i64 %i
526ff31fe3SThomas Lively}
536ff31fe3SThomas Lively
546ff31fe3SThomas Lively; CHECK-LABEL: implicit_def_f32:
55ef9d6aeaSHeejin Ahn; CHECK:      f32.const $push[[R:[0-9]+]]=, 0x0p0{{$}}
566ff31fe3SThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
576ff31fe3SThomas Livelydefine float @implicit_def_f32() {
586ff31fe3SThomas Lively  br i1 undef, label %A, label %X
596ff31fe3SThomas Lively
606ff31fe3SThomas LivelyA:                                                ; preds = %0
616ff31fe3SThomas Lively  %d = icmp slt i1 0, 0
626ff31fe3SThomas Lively  br i1 %d, label %C, label %B
636ff31fe3SThomas Lively
646ff31fe3SThomas LivelyB:                                                ; preds = %A
656ff31fe3SThomas Lively  br label %C
666ff31fe3SThomas Lively
676ff31fe3SThomas LivelyC:                                                ; preds = %B, %A
686ff31fe3SThomas Lively  %h = phi float [ undef, %A ], [ 0.0, %B ]
696ff31fe3SThomas Lively  br label %X
706ff31fe3SThomas Lively
716ff31fe3SThomas LivelyX:                                                ; preds = %0, C
726ff31fe3SThomas Lively  %i = phi float [ 1.0, %0 ], [ %h, %C ]
736ff31fe3SThomas Lively  ret float %i
746ff31fe3SThomas Lively}
756ff31fe3SThomas Lively
766ff31fe3SThomas Lively; CHECK-LABEL: implicit_def_f64:
77ef9d6aeaSHeejin Ahn; CHECK:      f64.const $push[[R:[0-9]+]]=, 0x0p0{{$}}
786ff31fe3SThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
796ff31fe3SThomas Livelydefine double @implicit_def_f64() {
806ff31fe3SThomas Lively  br i1 undef, label %A, label %X
816ff31fe3SThomas Lively
826ff31fe3SThomas LivelyA:                                                ; preds = %0
836ff31fe3SThomas Lively  %d = icmp slt i1 0, 0
846ff31fe3SThomas Lively  br i1 %d, label %C, label %B
856ff31fe3SThomas Lively
866ff31fe3SThomas LivelyB:                                                ; preds = %A
876ff31fe3SThomas Lively  br label %C
886ff31fe3SThomas Lively
896ff31fe3SThomas LivelyC:                                                ; preds = %B, %A
906ff31fe3SThomas Lively  %h = phi double [ undef, %A ], [ 0.0, %B ]
916ff31fe3SThomas Lively  br label %X
926ff31fe3SThomas Lively
936ff31fe3SThomas LivelyX:                                                ; preds = %0, C
946ff31fe3SThomas Lively  %i = phi double [ 1.0, %0 ], [ %h, %C ]
956ff31fe3SThomas Lively  ret double %i
966ff31fe3SThomas Lively}
976ff31fe3SThomas Lively
986ff31fe3SThomas Lively; CHECK-LABEL: implicit_def_v4i32:
99*e657c84fSThomas Lively; CHECK:      v128.const $push[[R:[0-9]+]]=, 0, 0{{$}}
1006ff31fe3SThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
1016ff31fe3SThomas Livelydefine <4 x i32> @implicit_def_v4i32() {
1026ff31fe3SThomas Lively  br i1 undef, label %A, label %X
1036ff31fe3SThomas Lively
1046ff31fe3SThomas LivelyA:                                                ; preds = %0
1056ff31fe3SThomas Lively  %d = icmp slt i1 0, 0
1066ff31fe3SThomas Lively  br i1 %d, label %C, label %B
1076ff31fe3SThomas Lively
1086ff31fe3SThomas LivelyB:                                                ; preds = %A
1096ff31fe3SThomas Lively  br label %C
1106ff31fe3SThomas Lively
1116ff31fe3SThomas LivelyC:                                                ; preds = %B, %A
1126ff31fe3SThomas Lively  %h = phi <4 x i32> [ undef, %A ], [ <i32 0, i32 0, i32 0, i32 0>, %B ]
1136ff31fe3SThomas Lively  br label %X
1146ff31fe3SThomas Lively
1156ff31fe3SThomas LivelyX:                                                ; preds = %0, C
1166ff31fe3SThomas Lively  %i = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %0 ], [ %h, %C ]
1176ff31fe3SThomas Lively  ret <4 x i32> %i
1186ff31fe3SThomas Lively}
119