control-flow-phi-inputs.js (1474B)
1 // Test the triangle pattern where the phi-input doesn't match the initial input. 2 // 3 // initialBlock 4 // / \ 5 // trueBranch | 6 // \ / 7 // phiBlock+falseBranch 8 // | 9 // testBlock 10 // 11 // Also see bug 1768346. 12 13 var f = wasmEvalText(`(module 14 (func (result i32) 15 block (result i32) 16 i32.const 0 ;; This must flow into the if below. 17 i32.const 1 18 br_if 0 19 drop 20 i32.const 1 21 end 22 if 23 i32.const 100 24 return 25 end 26 i32.const 200 27 ) 28 (export "" (func 0)) 29 )`).exports[""]; 30 31 assertEq(f(), 200); 32 33 var g = wasmEvalText(`(module 34 (func (result i32) 35 block (result i32) 36 i32.const 0 ;; This must flow into the if below. 37 i32.const 1 38 br_if 0 39 drop 40 i32.const 1 ;; This must flow into the if below 41 i32.const 1 42 br_if 0 43 drop 44 i32.const 1 45 end 46 if 47 i32.const 100 48 return 49 end 50 i32.const 200 51 ) 52 (export "" (func 0)) 53 )`).exports[""]; 54 55 assertEq(g(), 200); 56 57 var h = wasmEvalText(`(module 58 (func (param i32) (result i32) 59 block (result i32) 60 local.get 0 ;; This must flow into the if below. 61 local.get 0 62 br_if 0 63 drop 64 i32.const 0 ;; This must flow into the if below 65 i32.const 1 66 br_if 0 67 drop 68 i32.const 1 69 end 70 if 71 i32.const 100 72 return 73 end 74 i32.const 200 75 ) 76 (export "" (func 0)) 77 )`).exports[""]; 78 79 assertEq(h(0), 200); 80 assertEq(h(1), 100);