Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -290,6 +290,10 @@ disablePass(&PatchableFunctionID); disablePass(&ShrinkWrapID); + // This pass hurts code size for wasm because it can generate irreducible + // control flow. + disablePass(&MachineBlockPlacementID); + TargetPassConfig::addPostRegAlloc(); } Index: llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify.ll =================================================================== --- llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify.ll +++ llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify.ll @@ -1,5 +1,4 @@ ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -disable-block-placement -verify-machineinstrs -fast-isel=false -machine-sink-split-probability-threshold=0 -cgp-freq-ratio-to-skip-merge=1000 | FileCheck %s -; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -tail-dup-placement=0 -verify-machineinstrs -fast-isel=false -machine-sink-split-probability-threshold=0 -cgp-freq-ratio-to-skip-merge=1000 | FileCheck -check-prefix=OPT %s ; Test the CFG stackifier pass. @@ -27,16 +26,6 @@ ; CHECK-NEXT: br ; CHECK-NEXT: .LBB0_4: ; CHECK-NEXT: end_loop -; OPT-LABEL: test0: -; OPT: loop -; OPT: i32.ge_s -; OPT-NEXT: br_if -; OPT-NEXT: i32.const -; OPT-NEXT: i32.add -; OPT-NOT: br -; OPT: call -; OPT: br 0{{$}} -; OPT: return{{$}} define void @test0(i32 %n) { entry: br label %header @@ -72,16 +61,6 @@ ; CHECK-NEXT: br ; CHECK-NEXT: .LBB1_4: ; CHECK-NEXT: end_loop -; OPT-LABEL: test1: -; OPT: loop -; OPT: i32.ge_s -; OPT-NEXT: br_if -; OPT-NEXT: i32.const -; OPT-NEXT: i32.add -; OPT-NOT: br -; OPT: call -; OPT: br 0{{$}} -; OPT: return{{$}} define void @test1(i32 %n) { entry: br label %header @@ -114,17 +93,6 @@ ; CHECK: end_loop ; CHECK: end_block ; CHECK: return{{$}} -; OPT-LABEL: test2: -; OPT-NOT: local -; OPT: block {{$}} -; OPT: br_if 0, {{[^,]+}}{{$}} -; OPT: .LBB2_{{[0-9]+}}: -; OPT: loop -; OPT: br_if 0, $pop{{[0-9]+}}{{$}} -; OPT: .LBB2_{{[0-9]+}}: -; OPT: end_loop -; OPT: end_block -; OPT: return{{$}} define void @test2(double* nocapture %p, i32 %n) { entry: %cmp.4 = icmp sgt i32 %n, 0 @@ -166,20 +134,6 @@ ; CHECK-NEXT: end_block{{$}} ; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}} ; CHECK-NEXT: return $pop{{[0-9]+}}{{$}} -; OPT-LABEL: doublediamond: -; OPT: block {{$}} -; OPT-NEXT: block {{$}} -; OPT-NEXT: block {{$}} -; OPT: br_if 0, ${{[^,]+}}{{$}} -; OPT: br_if 1, ${{[^,]+}}{{$}} -; OPT: br 2{{$}} -; OPT-NEXT: .LBB3_3: -; OPT-NEXT: end_block -; OPT: br 1{{$}} -; OPT-NEXT: .LBB3_4: -; OPT: .LBB3_5: -; OPT-NEXT: end_block -; OPT: return $pop{{[0-9]+}}{{$}} define i32 @doublediamond(i32 %a, i32 %b, i32* %p) { entry: %c = icmp eq i32 %a, 0 @@ -208,11 +162,6 @@ ; CHECK: br_if 0, $1{{$}} ; CHECK: .LBB4_2: ; CHECK: return -; OPT-LABEL: triangle: -; OPT: block {{$}} -; OPT: br_if 0, $1{{$}} -; OPT: .LBB4_2: -; OPT: return define i32 @triangle(i32* %p, i32 %a) { entry: %c = icmp eq i32 %a, 0 @@ -235,15 +184,6 @@ ; CHECK: .LBB5_3: ; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}} ; CHECK-NEXT: return $pop{{[0-9]+}}{{$}} -; OPT-LABEL: diamond: -; OPT: block {{$}} -; OPT: block {{$}} -; OPT: br_if 0, {{[^,]+}}{{$}} -; OPT: br 1{{$}} -; OPT: .LBB5_2: -; OPT: .LBB5_3: -; OPT: i32.const $push{{[0-9]+}}=, 0{{$}} -; OPT-NEXT: return $pop{{[0-9]+}}{{$}} define i32 @diamond(i32* %p, i32 %a) { entry: %c = icmp eq i32 %a, 0 @@ -263,9 +203,6 @@ ; CHECK-LABEL: single_block: ; CHECK-NOT: br ; CHECK: return $pop{{[0-9]+}}{{$}} -; OPT-LABEL: single_block: -; OPT-NOT: br -; OPT: return $pop{{[0-9]+}}{{$}} define i32 @single_block(i32* %p) { entry: store volatile i32 0, i32* %p @@ -279,13 +216,6 @@ ; CHECK: i32.store 0($0), $pop{{[0-9]+}}{{$}} ; CHECK: br 0{{$}} ; CHECK: .LBB7_2: -; OPT-LABEL: minimal_loop: -; OPT-NOT: br -; OPT: .LBB7_1: -; OPT: loop i32 -; OPT: i32.store 0($0), $pop{{[0-9]+}}{{$}} -; OPT: br 0{{$}} -; OPT: .LBB7_2: define i32 @minimal_loop(i32* %p) { entry: store volatile i32 0, i32* %p @@ -303,14 +233,6 @@ ; CHECK-NEXT: end_loop{{$}} ; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}} ; CHECK-NEXT: return $pop{{[0-9]+}}{{$}} -; OPT-LABEL: simple_loop: -; OPT-NOT: br -; OPT: .LBB8_1: -; OPT: loop {{$}} -; OPT: br_if 0, {{[^,]+}}{{$}} -; OPT-NEXT: end_loop{{$}} -; OPT: i32.const $push{{[0-9]+}}=, 0{{$}} -; OPT-NEXT: return $pop{{[0-9]+}}{{$}} define i32 @simple_loop(i32* %p, i32 %a) { entry: %c = icmp eq i32 %a, 0 @@ -332,14 +254,6 @@ ; CHECK: .LBB9_3: ; CHECK: .LBB9_4: ; CHECK: return -; OPT-LABEL: doubletriangle: -; OPT: block {{$}} -; OPT: br_if 0, $0{{$}} -; OPT: block {{$}} -; OPT: br_if 0, $1{{$}} -; OPT: .LBB9_3: -; OPT: .LBB9_4: -; OPT: return define i32 @doubletriangle(i32 %a, i32 %b, i32* %p) { entry: %c = icmp eq i32 %a, 0 @@ -370,16 +284,6 @@ ; CHECK: .LBB10_4: ; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}} ; CHECK-NEXT: return $pop{{[0-9]+}}{{$}} -; OPT-LABEL: ifelse_earlyexits: -; OPT: block {{$}} -; OPT: block {{$}} -; OPT: br_if 0, {{[^,]+}}{{$}} -; OPT: br_if 1, $1{{$}} -; OPT: br 1{{$}} -; OPT: .LBB10_3: -; OPT: .LBB10_4: -; OPT: i32.const $push{{[0-9]+}}=, 0{{$}} -; OPT-NEXT: return $pop{{[0-9]+}}{{$}} define i32 @ifelse_earlyexits(i32 %a, i32 %b, i32* %p) { entry: %c = icmp eq i32 %a, 0 @@ -415,22 +319,6 @@ ; CHECK: br 0{{$}} ; CHECK: .LBB11_6: ; CHECK-NEXT: end_loop{{$}} -; OPT-LABEL: doublediamond_in_a_loop: -; OPT: .LBB11_1: -; OPT: loop i32{{$}} -; OPT: block {{$}} -; OPT: br_if 0, {{[^,]+}}{{$}} -; OPT: block {{$}} -; OPT: br_if 0, {{[^,]+}}{{$}} -; OPT: br 2{{$}} -; OPT-NEXT: .LBB11_4: -; OPT-NEXT: end_block{{$}} -; OPT: br 1{{$}} -; OPT: .LBB11_5: -; OPT-NEXT: end_block{{$}} -; OPT: br 0{{$}} -; OPT: .LBB11_6: -; OPT-NEXT: end_loop{{$}} define i32 @doublediamond_in_a_loop(i32 %a, i32 %b, i32* %p) { entry: br label %header @@ -463,27 +351,6 @@ ; CHECK-NEXT: br_if ; CHECK-NEXT: .LBB{{[0-9]+}}_{{[0-9]+}}: ; CHECK-NEXT: loop -; OPT-LABEL: test3: -; OPT: block -; OPT: br_if -; OPT: .LBB{{[0-9]+}}_{{[0-9]+}}: -; OPT-NEXT: loop -; OPT-NEXT: block -; OPT-NEXT: block -; OPT-NEXT: br_if -; OPT-NEXT: .LBB{{[0-9]+}}_{{[0-9]+}}: -; OPT-NEXT: loop -; OPT: br_if -; OPT-NEXT: br -; OPT-NEXT: .LBB{{[0-9]+}}_{{[0-9]+}}: -; OPT-NEXT: end_loop -; OPT-NEXT: end_block -; OPT-NEXT: unreachable -; OPT-NEXT: .LBB{{[0-9]+}}_{{[0-9]+}}: -; OPT-NEXT: end_block -; OPT: br -; OPT-NEXT: .LBB{{[0-9]+}}_{{[0-9]+}}: -; OPT-NEXT: end_loop declare void @bar() define void @test3(i32 %w) { entry: @@ -531,24 +398,6 @@ ; CHECK-NEXT: .LBB13_6: ; CHECK-NEXT: end_block{{$}} ; CHECK-NEXT: return{{$}} -; OPT-LABEL: test4: -; OPT-NEXT: .functype test4 (i32) -> (){{$}} -; OPT: block {{$}} -; OPT-NEXT: block {{$}} -; OPT: br_if 0, $pop{{[0-9]+}}{{$}} -; OPT: br_if 1, $pop{{[0-9]+}}{{$}} -; OPT: br 1{{$}} -; OPT-NEXT: .LBB13_3: -; OPT-NEXT: end_block{{$}} -; OPT-NEXT: block {{$}} -; OPT: br_if 0, $pop{{[0-9]+}}{{$}} -; OPT: br_if 1, $pop{{[0-9]+}}{{$}} -; OPT-NEXT: .LBB13_5: -; OPT-NEXT: end_block{{$}} -; OPT-NEXT: return{{$}} -; OPT-NEXT: .LBB13_6: -; OPT-NEXT: end_block{{$}} -; OPT-NEXT: return{{$}} define void @test4(i32 %t) { entry: switch i32 %t, label %default [ @@ -584,16 +433,6 @@ ; CHECK: return{{$}} ; CHECK-NEXT: .LBB14_4: ; CHECK: return{{$}} -; OPT-LABEL: test5: -; OPT: .LBB14_1: -; OPT-NEXT: block {{$}} -; OPT-NEXT: loop {{$}} -; OPT: br_if 1, {{[^,]+}}{{$}} -; OPT: br_if 0, {{[^,]+}}{{$}} -; OPT-NEXT: end_loop{{$}} -; OPT: return{{$}} -; OPT-NEXT: .LBB14_4: -; OPT: return{{$}} define void @test5(i1 %p, i1 %q) { entry: br label %header @@ -640,27 +479,6 @@ ; CHECK-NEXT: end_block{{$}} ; CHECK-NOT: block ; CHECK: return{{$}} -; OPT-LABEL: test6: -; OPT: .LBB15_1: -; OPT-NEXT: block {{$}} -; OPT-NEXT: block {{$}} -; OPT-NEXT: loop {{$}} -; OPT-NOT: block -; OPT: br_if 2, {{[^,]+}}{{$}} -; OPT-NOT: block -; OPT: br_if 1, {{[^,]+}}{{$}} -; OPT-NOT: block -; OPT: br_if 0, {{[^,]+}}{{$}} -; OPT-NEXT: end_loop{{$}} -; OPT-NOT: block -; OPT: return{{$}} -; OPT-NEXT: .LBB15_5: -; OPT-NEXT: end_block{{$}} -; OPT-NOT: block -; OPT: .LBB15_6: -; OPT-NEXT: end_block{{$}} -; OPT-NOT: block -; OPT: return{{$}} define void @test6(i1 %p, i1 %q) { entry: br label %header @@ -710,28 +528,6 @@ ; CHECK-NEXT: end_loop{{$}} ; CHECK-NOT: block ; CHECK: unreachable -; OPT-LABEL: test7: -; OPT: .LBB16_1: -; OPT-NEXT: block -; OPT-NEXT: loop {{$}} -; OPT-NOT: block -; OPT: block {{$}} -; OPT-NOT: block -; OPT: br_if 0, {{[^,]+}}{{$}} -; OPT-NOT: block -; OPT: br_if 1, {{[^,]+}}{{$}} -; OPT: br 2{{$}} -; OPT-NEXT: .LBB16_3: -; OPT-NEXT: end_block -; OPT-NOT: block -; OPT: br_if 0, {{[^,]+}}{{$}} -; OPT-NEXT: end_loop -; OPT-NOT: block -; OPT: unreachable -; OPT-NEXT: .LBB16_5: -; OPT-NEXT: end_block -; OPT-NOT: block -; OPT: unreachable define void @test7(i1 %tobool2, i1 %tobool9) { entry: store volatile i32 0, i32* null @@ -768,14 +564,6 @@ ; CHECK-NEXT: br 0{{$}} ; CHECK-NEXT: .LBB17_2: ; CHECK-NEXT: end_loop{{$}} -; OPT-LABEL: test8: -; OPT: .LBB17_1: -; OPT-NEXT: loop i32{{$}} -; OPT-NEXT: i32.const $push{{[^,]+}}, 0{{$}} -; OPT-NEXT: br_if 0, {{[^,]+}}{{$}} -; OPT-NEXT: br 0{{$}} -; OPT-NEXT: .LBB17_2: -; OPT-NEXT: end_loop{{$}} define i32 @test8() { bb: br label %bb1 @@ -821,31 +609,6 @@ ; CHECK: end_block ; CHECK-NOT: block ; CHECK: return{{$}} -; OPT-LABEL: test9: -; OPT: .LBB18_1: -; OPT-NEXT: block {{$}} -; OPT-NEXT: loop {{$}} -; OPT-NOT: block -; OPT: br_if 1, {{[^,]+}}{{$}} -; OPT-NEXT: .LBB18_2: -; OPT-NEXT: loop {{$}} -; OPT-NOT: block -; OPT: block {{$}} -; OPT-NOT: block -; OPT: br_if 0, {{[^,]+}}{{$}} -; OPT-NOT: block -; OPT: br_if 1, {{[^,]+}}{{$}} -; OPT-NEXT: br 2{{$}} -; OPT-NEXT: .LBB18_4: -; OPT-NEXT: end_block{{$}} -; OPT-NOT: block -; OPT: br_if 0, {{[^,]+}}{{$}} -; OPT-NEXT: br 1{{$}} -; OPT-NEXT: .LBB18_5: -; OPT-NOT: block -; OPT: end_block -; OPT-NOT: block -; OPT: return{{$}} declare i1 @a() define void @test9() { entry: @@ -906,32 +669,6 @@ ; CHECK-NOT: block ; CHECK: br 0{{$}} ; CHECK-NEXT: .LBB19_10: -; OPT-LABEL: test10: -; OPT: .LBB19_1: -; OPT-NEXT: loop {{$}} -; OPT-NOT: block -; OPT: br_if 0, {{[^,]+}}{{$}} -; OPT: .LBB19_3: -; OPT-NEXT: block {{$}} -; OPT-NEXT: loop {{$}} -; OPT-NOT: block -; OPT: .LBB19_4: -; OPT-NEXT: loop {{$}} -; OPT-NOT: block -; OPT: br_if 0, {{[^,]+}}{{$}} -; OPT-NEXT: end_loop{{$}} -; OPT: br_if 1, {{[^,]+}}{{$}} -; OPT-NOT: block -; OPT: br_if 0, {{[^,]+}}{{$}} -; OPT-NEXT: end_loop{{$}} -; OPT-NOT: block -; OPT: br_if 1, {{[^,]+}}{{$}} -; OPT-NEXT: return{{$}} -; OPT-NEXT: .LBB19_9: -; OPT-NEXT: end_block{{$}} -; OPT-NOT: block -; OPT: br 0{{$}} -; OPT-NEXT: .LBB19_10: define void @test10() { bb0: br label %bb1 @@ -1003,38 +740,6 @@ ; CHECK-NEXT: end_block{{$}} ; CHECK-NOT: block ; CHECK: return{{$}} -; OPT-LABEL: test11: -; OPT: block {{$}} -; OPT-NEXT: block {{$}} -; OPT: br_if 0, $pop{{[0-9]+}}{{$}} -; OPT-NOT: block -; OPT: block {{$}} -; OPT-NEXT: i32.const -; OPT-NEXT: br_if 0, {{[^,]+}}{{$}} -; OPT-NOT: block -; OPT: br_if 2, {{[^,]+}}{{$}} -; OPT-NEXT: .LBB20_3: -; OPT-NEXT: end_block{{$}} -; OPT-NOT: block -; OPT: return{{$}} -; OPT-NEXT: .LBB20_4: -; OPT-NEXT: end_block{{$}} -; OPT-NOT: block -; OPT: block {{$}} -; OPT-NOT: block -; OPT: br_if 0, $pop{{[0-9]+}}{{$}} -; OPT-NOT: block -; OPT: return{{$}} -; OPT-NEXT: .LBB20_6: -; OPT-NEXT: end_block{{$}} -; OPT-NOT: block -; OPT: br_if 0, $pop{{[0-9]+}}{{$}} -; OPT-NOT: block -; OPT: return{{$}} -; OPT-NEXT: .LBB20_8: -; OPT-NEXT: end_block{{$}} -; OPT-NOT: block -; OPT: return{{$}} define void @test11() { bb0: store volatile i32 0, i32* null @@ -1092,32 +797,6 @@ ; CHECK-NEXT: end_loop{{$}} ; CHECK-NEXT: end_block{{$}} ; CHECK-NEXT: return{{$}} -; OPT-LABEL: test12: -; OPT: .LBB21_1: -; OPT-NEXT: block {{$}} -; OPT-NEXT: loop {{$}} -; OPT-NOT: block -; OPT: block {{$}} -; OPT-NEXT: block {{$}} -; OPT: br_if 0, {{[^,]+}}{{$}} -; OPT-NOT: block -; OPT: br_if 1, {{[^,]+}}{{$}} -; OPT-NOT: block -; OPT: br_if 1, {{[^,]+}}{{$}} -; OPT-NEXT: br 3{{$}} -; OPT-NEXT: .LBB21_4: -; OPT-NEXT: end_block{{$}} -; OPT-NOT: block -; OPT: br_if 0, {{[^,]+}}{{$}} -; OPT-NOT: block -; OPT: br_if 2, {{[^,]+}}{{$}} -; OPT-NEXT: .LBB21_6: -; OPT-NEXT: end_block{{$}} -; OPT: br 0{{$}} -; OPT-NEXT: .LBB21_7: -; OPT-NEXT: end_loop{{$}} -; OPT-NEXT: end_block{{$}} -; OPT-NEXT: return{{$}} define void @test12(i8* %arg) { bb: br label %bb1 @@ -1161,22 +840,6 @@ ; CHECK-NEXT: .LBB22_5: ; CHECK-NEXT: end_block{{$}} ; CHECK-NEXT: unreachable{{$}} -; OPT-LABEL: test13: -; OPT: block {{$}} -; OPT-NEXT: block {{$}} -; OPT: br_if 0, $pop0{{$}} -; OPT: block {{$}} -; OPT: br_if 0, $pop3{{$}} -; OPT: .LBB22_3: -; OPT-NEXT: end_block{{$}} -; OPT: br_if 1, $pop{{[0-9]+}}{{$}} -; OPT-NEXT: br 1{{$}} -; OPT-NEXT: .LBB22_4: -; OPT-NEXT: end_block -; OPT-NEXT: return -; OPT-NEXT: .LBB22_5: -; OPT-NEXT: end_block{{$}} -; OPT-NEXT: unreachable{{$}} define void @test13() noinline optnone { bb: br i1 undef, label %bb5, label %bb2 @@ -1280,21 +943,6 @@ ; CHECK: .LBB24_8: ; CHECK-NEXT: end_block{{$}} ; CHECK-NEXT: return{{$}} -; OPT-LABEL: test15: -; OPT: block -; OPT: block -; OPT-NEXT: i32.const $push -; OPT-NEXT: i32.eqz $push{{.*}}=, $pop{{.*}}{{$}} -; OPT-NEXT: br_if 0, $pop{{.*}}{{$}} -; OPT-NEXT: call test15_callee1{{$}} -; OPT-NEXT: br 1{{$}} -; OPT-NEXT: .LBB24_2: -; OPT-NEXT: end_block -; OPT-NEXT: i32.const -; OPT-NEXT: .LBB24_3: -; OPT-NEXT: block -; OPT-NEXT: block -; OPT-NEXT: loop %0 = type { i8, i32 } declare void @test15_callee0() declare void @test15_callee1() Index: llvm/trunk/test/CodeGen/WebAssembly/conv-trap.ll =================================================================== --- llvm/trunk/test/CodeGen/WebAssembly/conv-trap.ll +++ llvm/trunk/test/CodeGen/WebAssembly/conv-trap.ll @@ -12,13 +12,14 @@ ; CHECK-NEXT: f32.abs $push[[ABS:[0-9]+]]=, $0{{$}} ; CHECK-NEXT: f32.const $push[[LIMIT:[0-9]+]]=, 0x1p31{{$}} ; CHECK-NEXT: f32.lt $push[[LT:[0-9]+]]=, $pop[[ABS]], $pop[[LIMIT]]{{$}} -; CHECK-NEXT: br_if 0, $pop[[LT]]{{$}} -; CHECK-NEXT: i32.const $push[[ALT:[0-9]+]]=, -2147483648{{$}} -; CHECK-NEXT: return $pop[[ALT]]{{$}} -; CHECK-NEXT: BB -; CHECK-NEXT: end_block +; CHECK-NEXT: i32.eqz $push[[EQZ:[0-9]+]]=, $pop[[LT]] +; CHECK-NEXT: br_if 0, $pop[[EQZ]]{{$}} ; CHECK-NEXT: i32.trunc_f32_s $push[[NUM:[0-9]+]]=, $0{{$}} ; CHECK-NEXT: return $pop[[NUM]]{{$}} +; CHECK-NEXT: BB +; CHECK-NEXT: end_block +; CHECK-NEXT: i32.const $push[[ALT:[0-9]+]]=, -2147483648{{$}} +; CHECK-NEXT: return $pop[[ALT]]{{$}} define i32 @i32_trunc_s_f32(float %x) { %a = fptosi float %x to i32 ret i32 %a @@ -32,13 +33,14 @@ ; CHECK-NEXT: f32.const $push[[ZERO:[0-9]+]]=, 0x0p0{{$}} ; CHECK-NEXT: f32.ge $push[[GE:[0-9]+]]=, $0, $pop[[ZERO]]{{$}} ; CHECK-NEXT: i32.and $push[[AND:[0-9]+]]=, $pop[[LT]], $pop[[GE]]{{$}} -; CHECK-NEXT: br_if 0, $pop[[AND]]{{$}} -; CHECK-NEXT: i32.const $push[[ALT:[0-9]+]]=, 0{{$}} -; CHECK-NEXT: return $pop[[ALT]]{{$}} -; CHECK-NEXT: BB -; CHECK-NEXT: end_block +; CHECK-NEXT: i32.eqz $push[[EQZ:[0-9]+]]=, $pop[[AND]] +; CHECK-NEXT: br_if 0, $pop[[EQZ]]{{$}} ; CHECK-NEXT: i32.trunc_f32_u $push[[NUM:[0-9]+]]=, $0{{$}} ; CHECK-NEXT: return $pop[[NUM]]{{$}} +; CHECK-NEXT: BB +; CHECK-NEXT: end_block +; CHECK-NEXT: i32.const $push[[ALT:[0-9]+]]=, 0{{$}} +; CHECK-NEXT: return $pop[[ALT]]{{$}} define i32 @i32_trunc_u_f32(float %x) { %a = fptoui float %x to i32 ret i32 %a @@ -50,13 +52,14 @@ ; CHECK-NEXT: f64.abs $push[[ABS:[0-9]+]]=, $0{{$}} ; CHECK-NEXT: f64.const $push[[LIMIT:[0-9]+]]=, 0x1p31{{$}} ; CHECK-NEXT: f64.lt $push[[LT:[0-9]+]]=, $pop[[ABS]], $pop[[LIMIT]]{{$}} -; CHECK-NEXT: br_if 0, $pop[[LT]]{{$}} -; CHECK-NEXT: i32.const $push[[ALT:[0-9]+]]=, -2147483648{{$}} -; CHECK-NEXT: return $pop[[ALT]]{{$}} -; CHECK-NEXT: BB -; CHECK-NEXT: end_block +; CHECK-NEXT: i32.eqz $push[[EQZ:[0-9]+]]=, $pop[[LT]] +; CHECK-NEXT: br_if 0, $pop[[EQZ]]{{$}} ; CHECK-NEXT: i32.trunc_f64_s $push[[NUM:[0-9]+]]=, $0{{$}} ; CHECK-NEXT: return $pop[[NUM]]{{$}} +; CHECK-NEXT: BB +; CHECK-NEXT: end_block +; CHECK-NEXT: i32.const $push[[ALT:[0-9]+]]=, -2147483648{{$}} +; CHECK-NEXT: return $pop[[ALT]]{{$}} define i32 @i32_trunc_s_f64(double %x) { %a = fptosi double %x to i32 ret i32 %a @@ -70,13 +73,14 @@ ; CHECK-NEXT: f64.const $push[[ZERO:[0-9]+]]=, 0x0p0{{$}} ; CHECK-NEXT: f64.ge $push[[GE:[0-9]+]]=, $0, $pop[[ZERO]]{{$}} ; CHECK-NEXT: i32.and $push[[AND:[0-9]+]]=, $pop[[LT]], $pop[[GE]]{{$}} -; CHECK-NEXT: br_if 0, $pop[[AND]]{{$}} -; CHECK-NEXT: i32.const $push[[ALT:[0-9]+]]=, 0{{$}} -; CHECK-NEXT: return $pop[[ALT]]{{$}} -; CHECK-NEXT: BB -; CHECK-NEXT: end_block +; CHECK-NEXT: i32.eqz $push[[EQZ:[0-9]+]]=, $pop[[AND]] +; CHECK-NEXT: br_if 0, $pop[[EQZ]]{{$}} ; CHECK-NEXT: i32.trunc_f64_u $push[[NUM:[0-9]+]]=, $0{{$}} ; CHECK-NEXT: return $pop[[NUM]]{{$}} +; CHECK-NEXT: BB +; CHECK-NEXT: end_block +; CHECK-NEXT: i32.const $push[[ALT:[0-9]+]]=, 0{{$}} +; CHECK-NEXT: return $pop[[ALT]]{{$}} define i32 @i32_trunc_u_f64(double %x) { %a = fptoui double %x to i32 ret i32 %a @@ -88,13 +92,14 @@ ; CHECK-NEXT: f32.abs $push[[ABS:[0-9]+]]=, $0{{$}} ; CHECK-NEXT: f32.const $push[[LIMIT:[0-9]+]]=, 0x1p63{{$}} ; CHECK-NEXT: f32.lt $push[[LT:[0-9]+]]=, $pop[[ABS]], $pop[[LIMIT]]{{$}} -; CHECK-NEXT: br_if 0, $pop[[LT]]{{$}} -; CHECK-NEXT: i64.const $push[[ALT:[0-9]+]]=, -9223372036854775808{{$}} -; CHECK-NEXT: return $pop[[ALT]]{{$}} -; CHECK-NEXT: BB -; CHECK-NEXT: end_block +; CHECK-NEXT: i32.eqz $push[[EQZ:[0-9]+]]=, $pop[[LT]] +; CHECK-NEXT: br_if 0, $pop[[EQZ]]{{$}} ; CHECK-NEXT: i64.trunc_f32_s $push[[NUM:[0-9]+]]=, $0{{$}} ; CHECK-NEXT: return $pop[[NUM]]{{$}} +; CHECK-NEXT: BB +; CHECK-NEXT: end_block +; CHECK-NEXT: i64.const $push[[ALT:[0-9]+]]=, -9223372036854775808{{$}} +; CHECK-NEXT: return $pop[[ALT]]{{$}} define i64 @i64_trunc_s_f32(float %x) { %a = fptosi float %x to i64 ret i64 %a @@ -108,13 +113,14 @@ ; CHECK-NEXT: f32.const $push[[ZERO:[0-9]+]]=, 0x0p0{{$}} ; CHECK-NEXT: f32.ge $push[[GE:[0-9]+]]=, $0, $pop[[ZERO]]{{$}} ; CHECK-NEXT: i32.and $push[[AND:[0-9]+]]=, $pop[[LT]], $pop[[GE]]{{$}} -; CHECK-NEXT: br_if 0, $pop[[AND]]{{$}} -; CHECK-NEXT: i64.const $push[[ALT:[0-9]+]]=, 0{{$}} -; CHECK-NEXT: return $pop[[ALT]]{{$}} -; CHECK-NEXT: BB -; CHECK-NEXT: end_block +; CHECK-NEXT: i32.eqz $push[[EQZ:[0-9]+]]=, $pop[[AND]] +; CHECK-NEXT: br_if 0, $pop[[EQZ]]{{$}} ; CHECK-NEXT: i64.trunc_f32_u $push[[NUM:[0-9]+]]=, $0{{$}} ; CHECK-NEXT: return $pop[[NUM]]{{$}} +; CHECK-NEXT: BB +; CHECK-NEXT: end_block +; CHECK-NEXT: i64.const $push[[ALT:[0-9]+]]=, 0{{$}} +; CHECK-NEXT: return $pop[[ALT]]{{$}} define i64 @i64_trunc_u_f32(float %x) { %a = fptoui float %x to i64 ret i64 %a @@ -126,13 +132,14 @@ ; CHECK-NEXT: f64.abs $push[[ABS:[0-9]+]]=, $0{{$}} ; CHECK-NEXT: f64.const $push[[LIMIT:[0-9]+]]=, 0x1p63{{$}} ; CHECK-NEXT: f64.lt $push[[LT:[0-9]+]]=, $pop[[ABS]], $pop[[LIMIT]]{{$}} -; CHECK-NEXT: br_if 0, $pop[[LT]]{{$}} -; CHECK-NEXT: i64.const $push[[ALT:[0-9]+]]=, -9223372036854775808{{$}} -; CHECK-NEXT: return $pop[[ALT]]{{$}} -; CHECK-NEXT: BB -; CHECK-NEXT: end_block +; CHECK-NEXT: i32.eqz $push[[EQZ:[0-9]+]]=, $pop[[LT]] +; CHECK-NEXT: br_if 0, $pop[[EQZ]]{{$}} ; CHECK-NEXT: i64.trunc_f64_s $push[[NUM:[0-9]+]]=, $0{{$}} ; CHECK-NEXT: return $pop[[NUM]]{{$}} +; CHECK-NEXT: BB +; CHECK-NEXT: end_block +; CHECK-NEXT: i64.const $push[[ALT:[0-9]+]]=, -9223372036854775808{{$}} +; CHECK-NEXT: return $pop[[ALT]]{{$}} define i64 @i64_trunc_s_f64(double %x) { %a = fptosi double %x to i64 ret i64 %a @@ -146,13 +153,14 @@ ; CHECK-NEXT: f64.const $push[[ZERO:[0-9]+]]=, 0x0p0{{$}} ; CHECK-NEXT: f64.ge $push[[GE:[0-9]+]]=, $0, $pop[[ZERO]]{{$}} ; CHECK-NEXT: i32.and $push[[AND:[0-9]+]]=, $pop[[LT]], $pop[[GE]]{{$}} -; CHECK-NEXT: br_if 0, $pop[[AND]]{{$}} -; CHECK-NEXT: i64.const $push[[ALT:[0-9]+]]=, 0{{$}} -; CHECK-NEXT: return $pop[[ALT]]{{$}} -; CHECK-NEXT: BB -; CHECK-NEXT: end_block +; CHECK-NEXT: i32.eqz $push[[EQZ:[0-9]+]]=, $pop[[AND]] +; CHECK-NEXT: br_if 0, $pop[[EQZ]]{{$}} ; CHECK-NEXT: i64.trunc_f64_u $push[[NUM:[0-9]+]]=, $0{{$}} ; CHECK-NEXT: return $pop[[NUM]]{{$}} +; CHECK-NEXT: BB +; CHECK-NEXT: end_block +; CHECK-NEXT: i64.const $push[[ALT:[0-9]+]]=, 0{{$}} +; CHECK-NEXT: return $pop[[ALT]]{{$}} define i64 @i64_trunc_u_f64(double %x) { %a = fptoui double %x to i64 ret i64 %a Index: llvm/trunk/test/CodeGen/WebAssembly/implicit-def.ll =================================================================== --- llvm/trunk/test/CodeGen/WebAssembly/implicit-def.ll +++ llvm/trunk/test/CodeGen/WebAssembly/implicit-def.ll @@ -7,11 +7,10 @@ ; CONST_XXX instructions to provide an explicit push. ; CHECK-LABEL: implicit_def_i32: -; CHECK: .LBB{{[0-9]+}}_4:{{$}} -; CHECK-NEXT: end_block{{$}} -; CHECK-NEXT: i32.const $push[[R:[0-9]+]]=, 0{{$}} +; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}} +; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}} +; CHECK: i32.const $push[[R:[0-9]+]]=, 0{{$}} ; CHECK-NEXT: return $pop[[R]]{{$}} -; CHECK-NEXT: end_function{{$}} define i32 @implicit_def_i32() { br i1 undef, label %A, label %X @@ -32,11 +31,8 @@ } ; CHECK-LABEL: implicit_def_i64: -; CHECK: .LBB{{[0-9]+}}_4:{{$}} -; CHECK-NEXT: end_block{{$}} -; CHECK-NEXT: i64.const $push[[R:[0-9]+]]=, 0{{$}} +; CHECK: i64.const $push[[R:[0-9]+]]=, 0{{$}} ; CHECK-NEXT: return $pop[[R]]{{$}} -; CHECK-NEXT: end_function{{$}} define i64 @implicit_def_i64() { br i1 undef, label %A, label %X @@ -57,11 +53,8 @@ } ; CHECK-LABEL: implicit_def_f32: -; CHECK: .LBB{{[0-9]+}}_4:{{$}} -; CHECK-NEXT: end_block{{$}} -; CHECK-NEXT: f32.const $push[[R:[0-9]+]]=, 0x0p0{{$}} +; CHECK: f32.const $push[[R:[0-9]+]]=, 0x0p0{{$}} ; CHECK-NEXT: return $pop[[R]]{{$}} -; CHECK-NEXT: end_function{{$}} define float @implicit_def_f32() { br i1 undef, label %A, label %X @@ -82,11 +75,8 @@ } ; CHECK-LABEL: implicit_def_f64: -; CHECK: .LBB{{[0-9]+}}_4:{{$}} -; CHECK-NEXT: end_block{{$}} -; CHECK-NEXT: f64.const $push[[R:[0-9]+]]=, 0x0p0{{$}} +; CHECK: f64.const $push[[R:[0-9]+]]=, 0x0p0{{$}} ; CHECK-NEXT: return $pop[[R]]{{$}} -; CHECK-NEXT: end_function{{$}} define double @implicit_def_f64() { br i1 undef, label %A, label %X @@ -107,12 +97,11 @@ } ; CHECK-LABEL: implicit_def_v4i32: -; CHECK: .LBB{{[0-9]+}}_4:{{$}} -; CHECK-NEXT: end_block{{$}} -; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 0{{$}} +; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}} +; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}} +; CHECK: i32.const $push[[L0:[0-9]+]]=, 0{{$}} ; CHECK-NEXT: i32x4.splat $push[[R:[0-9]+]]=, $pop[[L0]] ; CHECK-NEXT: return $pop[[R]]{{$}} -; CHECK-NEXT: end_function{{$}} define <4 x i32> @implicit_def_v4i32() { br i1 undef, label %A, label %X Index: llvm/trunk/test/CodeGen/WebAssembly/lower-global-dtors.ll =================================================================== --- llvm/trunk/test/CodeGen/WebAssembly/lower-global-dtors.ll +++ llvm/trunk/test/CodeGen/WebAssembly/lower-global-dtors.ll @@ -49,10 +49,10 @@ ; CHECK-NEXT: i32.const $push1=, 0 ; CHECK-NEXT: i32.const $push0=, __dso_handle ; CHECK-NEXT: i32.call $push3=, __cxa_atexit, $pop2, $pop1, $pop0{{$}} -; CHECK-NEXT: br_if 0, $pop3 -; CHECK-NEXT: return -; CHECK: end_block +; CHECK-NEXT: i32.eqz $push4=, $pop3 +; CHECK-NEXT: br_if 0, $pop4 ; CHECK-NEXT: unreachable +; CHECK: end_block ; CHECK-LABEL: .Lcall_dtors.1: ; CHECK-NEXT: .functype .Lcall_dtors.1 (i32) -> (){{$}} @@ -65,10 +65,10 @@ ; CHECK-NEXT: i32.const $push1=, 0 ; CHECK-NEXT: i32.const $push0=, __dso_handle ; CHECK-NEXT: i32.call $push3=, __cxa_atexit, $pop2, $pop1, $pop0{{$}} -; CHECK-NEXT: br_if 0, $pop3 -; CHECK-NEXT: return -; CHECK: end_block +; CHECK-NEXT: i32.eqz $push4=, $pop3 +; CHECK-NEXT: br_if 0, $pop4 ; CHECK-NEXT: unreachable +; CHECK: end_block ; CHECK-LABEL: .Lcall_dtors.1.associated1c0: ; CHECK-NEXT: .functype .Lcall_dtors.1.associated1c0 (i32) -> (){{$}} @@ -80,9 +80,8 @@ ; CHECK-NEXT: i32.const $push1=, 0 ; CHECK-NEXT: i32.const $push0=, __dso_handle ; CHECK-NEXT: i32.call $push3=, __cxa_atexit, $pop2, $pop1, $pop0{{$}} -; CHECK-NEXT: br_if 0, $pop3 -; CHECK-NEXT: return -; CHECK: end_block +; CHECK-NEXT: i32.eqz $push4=, $pop3 +; CHECK-NEXT: br_if 0, $pop4 ; CHECK-NEXT: unreachable ; CHECK-LABEL: .Lcall_dtors.1.associated1c1: @@ -96,9 +95,8 @@ ; CHECK-NEXT: i32.const $push1=, 0 ; CHECK-NEXT: i32.const $push0=, __dso_handle ; CHECK-NEXT: i32.call $push3=, __cxa_atexit, $pop2, $pop1, $pop0{{$}} -; CHECK-NEXT: br_if 0, $pop3 -; CHECK-NEXT: return -; CHECK: end_block +; CHECK-NEXT: i32.eqz $push4=, $pop3 +; CHECK-NEXT: br_if 0, $pop4 ; CHECK-NEXT: unreachable ; CHECK-LABEL: .Lcall_dtors: @@ -111,9 +109,8 @@ ; CHECK-NEXT: i32.const $push1=, 0 ; CHECK-NEXT: i32.const $push0=, __dso_handle ; CHECK-NEXT: i32.call $push3=, __cxa_atexit, $pop2, $pop1, $pop0{{$}} -; CHECK-NEXT: br_if 0, $pop3 -; CHECK-NEXT: return -; CHECK: end_block +; CHECK-NEXT: i32.eqz $push4=, $pop3 +; CHECK-NEXT: br_if 0, $pop4 ; CHECK-NEXT: unreachable ; CHECK-LABEL: .section .init_array.0,"",@ Index: llvm/trunk/test/CodeGen/WebAssembly/phi.ll =================================================================== --- llvm/trunk/test/CodeGen/WebAssembly/phi.ll +++ llvm/trunk/test/CodeGen/WebAssembly/phi.ll @@ -8,9 +8,8 @@ ; Basic phi triangle. ; CHECK-LABEL: test0: -; CHECK: return $0 -; CHECK: div_s $push[[NUM0:[0-9]+]]=, $0, $pop[[NUM1:[0-9]+]]{{$}} -; CHECK: return $pop[[NUM0]]{{$}} +; CHECK: div_s $[[NUM0:[0-9]+]]=, $0, $pop[[NUM1:[0-9]+]]{{$}} +; CHECK: return $[[NUM0]]{{$}} define i32 @test0(i32 %p) { entry: %t = icmp slt i32 %p, 0 Index: llvm/trunk/test/MC/WebAssembly/global-ctor-dtor.ll =================================================================== --- llvm/trunk/test/MC/WebAssembly/global-ctor-dtor.ll +++ llvm/trunk/test/MC/WebAssembly/global-ctor-dtor.ll @@ -93,13 +93,13 @@ ; CHECK-NEXT: Body: 1080808080000B ; CHECK-NEXT: - Index: 6 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 024041818080800041004180808080001081808080000D000F0B00000B +; CHECK-NEXT: Body: 02404181808080004100418080808000108180808000450D0000000B0B ; CHECK-NEXT: - Index: 7 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 1082808080000B ; CHECK-NEXT: - Index: 8 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 024041828080800041004180808080001081808080000D000F0B00000B +; CHECK-NEXT: Body: 02404182808080004100418080808000108180808000450D0000000B0B ; CHECK-NEXT: - Type: DATA ; CHECK-NEXT: Segments: ; CHECK-NEXT: - SectionOffset: 6