|
| 1 | +;; Regression tests asserting that `fuse-eqz` and `fuse-nez` properly |
| 2 | +;; update the type of the resulting operand they successfully fused. |
| 3 | +;; |
| 4 | +;; The bug made translation of `i64.extend_i32_u` panic since `fuse-eqz` |
| 5 | +;; and `fuse-nez` did not properly update the type on the translation type |
| 6 | +;; upon successful op-code fusion. |
| 7 | + |
| 8 | +(module |
| 9 | + ;; fuse-nez |
| 10 | + |
| 11 | + (func (export "fuse.and+eqz") (param i64 i64) (result i64) |
| 12 | + (i64.eqz (i64.and (local.get 0) (local.get 1))) |
| 13 | + i64.extend_i32_u |
| 14 | + ) |
| 15 | + |
| 16 | + (func (export "fuse.or+eqz") (param i64 i64) (result i64) |
| 17 | + (i64.eqz (i64.or (local.get 0) (local.get 1))) |
| 18 | + i64.extend_i32_u |
| 19 | + ) |
| 20 | + |
| 21 | + (func (export "fuse.xor+eqz") (param i64 i64) (result i64) |
| 22 | + (i64.eqz (i64.xor (local.get 0) (local.get 1))) |
| 23 | + i64.extend_i32_u |
| 24 | + ) |
| 25 | + |
| 26 | + ;; fuse-nez |
| 27 | + |
| 28 | + (func (export "fuse.and+nez") (param i64 i64) (result i64) |
| 29 | + (i64.ne |
| 30 | + (i64.and (local.get 0) (local.get 1)) |
| 31 | + (i64.const 0) |
| 32 | + ) |
| 33 | + i64.extend_i32_u |
| 34 | + ) |
| 35 | + |
| 36 | + (func (export "fuse.or+nez") (param i64 i64) (result i64) |
| 37 | + (i64.ne |
| 38 | + (i64.or (local.get 0) (local.get 1)) |
| 39 | + (i64.const 0) |
| 40 | + ) |
| 41 | + i64.extend_i32_u |
| 42 | + ) |
| 43 | + |
| 44 | + (func (export "fuse.xor+nez") (param i64 i64) (result i64) |
| 45 | + (i64.ne |
| 46 | + (i64.xor (local.get 0) (local.get 1)) |
| 47 | + (i64.const 0) |
| 48 | + ) |
| 49 | + i64.extend_i32_u |
| 50 | + ) |
| 51 | +) |
| 52 | + |
| 53 | +;; and + eqz |
| 54 | + |
| 55 | +(assert_return |
| 56 | + (invoke "fuse.and+eqz" (i64.const 0) (i64.const 0)) |
| 57 | + (i64.const 1) |
| 58 | +) |
| 59 | +(assert_return |
| 60 | + (invoke "fuse.and+eqz" (i64.const 0) (i64.const 1)) |
| 61 | + (i64.const 1) |
| 62 | +) |
| 63 | +(assert_return |
| 64 | + (invoke "fuse.and+eqz" (i64.const 1) (i64.const 0)) |
| 65 | + (i64.const 1) |
| 66 | +) |
| 67 | +(assert_return |
| 68 | + (invoke "fuse.and+eqz" (i64.const 1) (i64.const 1)) |
| 69 | + (i64.const 0) |
| 70 | +) |
| 71 | + |
| 72 | +;; or + eqz |
| 73 | + |
| 74 | +(assert_return |
| 75 | + (invoke "fuse.or+eqz" (i64.const 0) (i64.const 0)) |
| 76 | + (i64.const 1) |
| 77 | +) |
| 78 | +(assert_return |
| 79 | + (invoke "fuse.or+eqz" (i64.const 0) (i64.const 1)) |
| 80 | + (i64.const 0) |
| 81 | +) |
| 82 | +(assert_return |
| 83 | + (invoke "fuse.or+eqz" (i64.const 1) (i64.const 0)) |
| 84 | + (i64.const 0) |
| 85 | +) |
| 86 | +(assert_return |
| 87 | + (invoke "fuse.or+eqz" (i64.const 1) (i64.const 1)) |
| 88 | + (i64.const 0) |
| 89 | +) |
| 90 | + |
| 91 | +;; xor + eqz |
| 92 | + |
| 93 | +(assert_return |
| 94 | + (invoke "fuse.xor+eqz" (i64.const 0) (i64.const 0)) |
| 95 | + (i64.const 1) |
| 96 | +) |
| 97 | +(assert_return |
| 98 | + (invoke "fuse.xor+eqz" (i64.const 0) (i64.const 1)) |
| 99 | + (i64.const 0) |
| 100 | +) |
| 101 | +(assert_return |
| 102 | + (invoke "fuse.xor+eqz" (i64.const 1) (i64.const 0)) |
| 103 | + (i64.const 0) |
| 104 | +) |
| 105 | +(assert_return |
| 106 | + (invoke "fuse.xor+eqz" (i64.const 1) (i64.const 1)) |
| 107 | + (i64.const 1) |
| 108 | +) |
| 109 | + |
| 110 | +;; and + nez |
| 111 | + |
| 112 | +(assert_return |
| 113 | + (invoke "fuse.and+nez" (i64.const 0) (i64.const 0)) |
| 114 | + (i64.const 0) |
| 115 | +) |
| 116 | +(assert_return |
| 117 | + (invoke "fuse.and+nez" (i64.const 0) (i64.const 1)) |
| 118 | + (i64.const 0) |
| 119 | +) |
| 120 | +(assert_return |
| 121 | + (invoke "fuse.and+nez" (i64.const 1) (i64.const 0)) |
| 122 | + (i64.const 0) |
| 123 | +) |
| 124 | +(assert_return |
| 125 | + (invoke "fuse.and+nez" (i64.const 1) (i64.const 1)) |
| 126 | + (i64.const 1) |
| 127 | +) |
| 128 | + |
| 129 | +;; or + nez |
| 130 | + |
| 131 | +(assert_return |
| 132 | + (invoke "fuse.or+nez" (i64.const 0) (i64.const 0)) |
| 133 | + (i64.const 0) |
| 134 | +) |
| 135 | +(assert_return |
| 136 | + (invoke "fuse.or+nez" (i64.const 0) (i64.const 1)) |
| 137 | + (i64.const 1) |
| 138 | +) |
| 139 | +(assert_return |
| 140 | + (invoke "fuse.or+nez" (i64.const 1) (i64.const 0)) |
| 141 | + (i64.const 1) |
| 142 | +) |
| 143 | +(assert_return |
| 144 | + (invoke "fuse.or+nez" (i64.const 1) (i64.const 1)) |
| 145 | + (i64.const 1) |
| 146 | +) |
| 147 | + |
| 148 | +;; xor + nez |
| 149 | + |
| 150 | +(assert_return |
| 151 | + (invoke "fuse.xor+nez" (i64.const 0) (i64.const 0)) |
| 152 | + (i64.const 0) |
| 153 | +) |
| 154 | +(assert_return |
| 155 | + (invoke "fuse.xor+nez" (i64.const 0) (i64.const 1)) |
| 156 | + (i64.const 1) |
| 157 | +) |
| 158 | +(assert_return |
| 159 | + (invoke "fuse.xor+nez" (i64.const 1) (i64.const 0)) |
| 160 | + (i64.const 1) |
| 161 | +) |
| 162 | +(assert_return |
| 163 | + (invoke "fuse.xor+nez" (i64.const 1) (i64.const 1)) |
| 164 | + (i64.const 0) |
| 165 | +) |
0 commit comments