1 ; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-block-placement -disable-wasm-explicit-locals | FileCheck %s
3 ; Test irreducible CFG handling.
5 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
6 target triple = "wasm32-unknown-unknown"
8 ; A simple loop with two entries.
12 ; CHECK: i32.const $[[REG:[^,]+]]=, 0{{$}}
13 ; CHECK: br_table $[[REG]],
14 define void @test0(double* %arg, i32 %arg1, i32 %arg2, i32 %arg3) {
16 %tmp = icmp eq i32 %arg2, 0
17 br i1 %tmp, label %bb6, label %bb3
20 %tmp4 = getelementptr double, double* %arg, i32 %arg3
21 %tmp5 = load double, double* %tmp4, align 4
25 %tmp7 = phi i32 [ %tmp18, %bb13 ], [ 0, %bb ]
26 %tmp8 = icmp slt i32 %tmp7, %arg1
27 br i1 %tmp8, label %bb9, label %bb19
30 %tmp10 = getelementptr double, double* %arg, i32 %tmp7
31 %tmp11 = load double, double* %tmp10, align 4
32 %tmp12 = fmul double %tmp11, 2.300000e+00
33 store double %tmp12, double* %tmp10, align 4
37 %tmp14 = phi double [ %tmp5, %bb3 ], [ %tmp12, %bb9 ]
38 %tmp15 = phi i32 [ undef, %bb3 ], [ %tmp7, %bb9 ]
39 %tmp16 = getelementptr double, double* %arg, i32 %tmp15
40 %tmp17 = fadd double %tmp14, 1.300000e+00
41 store double %tmp17, double* %tmp16, align 4
42 %tmp18 = add nsw i32 %tmp15, 1
49 ; A simple loop with two entries and an inner natural loop.
53 ; CHECK: i32.const $[[REG:[^,]+]]=, 0{{$}}
54 ; CHECK: br_table $[[REG]],
55 define void @test1(double* %arg, i32 %arg1, i32 %arg2, i32 %arg3) {
57 %tmp = icmp eq i32 %arg2, 0
58 br i1 %tmp, label %bb6, label %bb3
61 %tmp4 = getelementptr double, double* %arg, i32 %arg3
62 %tmp5 = load double, double* %tmp4, align 4
66 %tmp7 = phi i32 [ %tmp18, %bb13 ], [ 0, %bb ]
67 %tmp8 = icmp slt i32 %tmp7, %arg1
68 br i1 %tmp8, label %bb9, label %bb19
71 %tmp10 = getelementptr double, double* %arg, i32 %tmp7
72 %tmp11 = load double, double* %tmp10, align 4
73 %tmp12 = fmul double %tmp11, 2.300000e+00
74 store double %tmp12, double* %tmp10, align 4
78 %p = phi i32 [ 0, %bb9 ], [ %pn, %bb10 ]
80 %c = icmp slt i32 %pn, 256
81 br i1 %c, label %bb10, label %bb13
84 %tmp14 = phi double [ %tmp5, %bb3 ], [ %tmp12, %bb10 ]
85 %tmp15 = phi i32 [ undef, %bb3 ], [ %tmp7, %bb10 ]
86 %tmp16 = getelementptr double, double* %arg, i32 %tmp15
87 %tmp17 = fadd double %tmp14, 1.300000e+00
88 store double %tmp17, double* %tmp16, align 4
89 %tmp18 = add nsw i32 %tmp15, 1