|
153 | 153 | (Not (ConstBool [c])) -> (ConstBool [1-c])
|
154 | 154 |
|
155 | 155 | // Convert x * 1 to x.
|
156 |
| -(Mul8 (Const8 [1]) x) -> x |
157 |
| -(Mul16 (Const16 [1]) x) -> x |
158 |
| -(Mul32 (Const32 [1]) x) -> x |
159 |
| -(Mul64 (Const64 [1]) x) -> x |
| 156 | +(Mul(8|16|32|64) (Const(8|16|32|64) [1]) x) -> x |
160 | 157 |
|
161 | 158 | // Convert x * -1 to -x.
|
162 |
| -(Mul8 (Const8 [-1]) x) -> (Neg8 x) |
163 |
| -(Mul16 (Const16 [-1]) x) -> (Neg16 x) |
164 |
| -(Mul32 (Const32 [-1]) x) -> (Neg32 x) |
165 |
| -(Mul64 (Const64 [-1]) x) -> (Neg64 x) |
| 159 | +(Mul(8|16|32|64) (Const(8|16|32|64) [-1]) x) -> (Neg(8|16|32|64) x) |
166 | 160 |
|
167 | 161 | // Convert multiplication by a power of two to a shift.
|
168 | 162 | (Mul8 <t> n (Const8 [c])) && isPowerOfTwo(c) -> (Lsh8x64 <t> n (Const64 <typ.UInt64> [log2(c)]))
|
|
457 | 451 | // simplifications
|
458 | 452 | (Or(64|32|16|8) x x) -> x
|
459 | 453 | (Or(64|32|16|8) (Const(64|32|16|8) [0]) x) -> x
|
460 |
| -(Or64 (Const64 [-1]) _) -> (Const64 [-1]) |
461 |
| -(Or32 (Const32 [-1]) _) -> (Const32 [-1]) |
462 |
| -(Or16 (Const16 [-1]) _) -> (Const16 [-1]) |
463 |
| -(Or8 (Const8 [-1]) _) -> (Const8 [-1]) |
| 454 | +(Or(64|32|16|8) (Const(64|32|16|8) [-1]) _) -> (Const(64|32|16|8) [-1]) |
| 455 | + |
464 | 456 | (And(64|32|16|8) x x) -> x
|
465 | 457 | (And(64|32|16|8) (Const(64|32|16|8) [-1]) x) -> x
|
466 |
| -(And64 (Const64 [0]) _) -> (Const64 [0]) |
467 |
| -(And32 (Const32 [0]) _) -> (Const32 [0]) |
468 |
| -(And16 (Const16 [0]) _) -> (Const16 [0]) |
469 |
| -(And8 (Const8 [0]) _) -> (Const8 [0]) |
470 |
| -(Xor64 x x) -> (Const64 [0]) |
471 |
| -(Xor32 x x) -> (Const32 [0]) |
472 |
| -(Xor16 x x) -> (Const16 [0]) |
473 |
| -(Xor8 x x) -> (Const8 [0]) |
| 458 | +(And(64|32|16|8) (Const(64|32|16|8) [0]) _) -> (Const(64|32|16|8) [0]) |
| 459 | + |
| 460 | +(Xor(64|32|16|8) x x) -> (Const(64|32|16|8) [0]) |
474 | 461 | (Xor(64|32|16|8) (Const(64|32|16|8) [0]) x) -> x
|
| 462 | + |
475 | 463 | (Add(64|32|16|8) (Const(64|32|16|8) [0]) x) -> x
|
476 |
| -(Sub64 x x) -> (Const64 [0]) |
477 |
| -(Sub32 x x) -> (Const32 [0]) |
478 |
| -(Sub16 x x) -> (Const16 [0]) |
479 |
| -(Sub8 x x) -> (Const8 [0]) |
480 |
| -(Mul64 (Const64 [0]) _) -> (Const64 [0]) |
481 |
| -(Mul32 (Const32 [0]) _) -> (Const32 [0]) |
482 |
| -(Mul16 (Const16 [0]) _) -> (Const16 [0]) |
483 |
| -(Mul8 (Const8 [0]) _) -> (Const8 [0]) |
| 464 | +(Sub(64|32|16|8) x x) -> (Const(64|32|16|8) [0]) |
| 465 | +(Mul(64|32|16|8) (Const(64|32|16|8) [0]) _) -> (Const(64|32|16|8) [0]) |
| 466 | + |
484 | 467 | (Com(64|32|16|8) (Com(64|32|16|8) x)) -> x
|
485 |
| -(Com8 (Const8 [c])) -> (Const8 [^c]) |
486 |
| -(Com16 (Const16 [c])) -> (Const16 [^c]) |
487 |
| -(Com32 (Const32 [c])) -> (Const32 [^c]) |
488 |
| -(Com64 (Const64 [c])) -> (Const64 [^c]) |
489 |
| -(Neg8 (Sub8 x y)) -> (Sub8 y x) |
490 |
| -(Neg16 (Sub16 x y)) -> (Sub16 y x) |
491 |
| -(Neg32 (Sub32 x y)) -> (Sub32 y x) |
492 |
| -(Neg64 (Sub64 x y)) -> (Sub64 y x) |
| 468 | +(Com(64|32|16|8) (Const(64|32|16|8) [c])) -> (Const(64|32|16|8) [^c]) |
| 469 | + |
| 470 | +(Neg(64|32|16|8) (Sub(64|32|16|8) x y)) -> (Sub(64|32|16|8) y x) |
| 471 | + |
493 | 472 | (Add8 (Const8 [1]) (Com8 x)) -> (Neg8 x)
|
494 | 473 | (Add16 (Const16 [1]) (Com16 x)) -> (Neg16 x)
|
495 | 474 | (Add32 (Const32 [1]) (Com32 x)) -> (Neg32 x)
|
|
1229 | 1208 | (Mul8 (Const8 <t> [c]) (Mul8 (Const8 <t> [d]) x)) -> (Mul8 (Const8 <t> [int64(int8(c*d))]) x)
|
1230 | 1209 |
|
1231 | 1210 | // floating point optimizations
|
1232 |
| -(Add32F x (Const32F [0])) -> x |
1233 |
| -(Add64F x (Const64F [0])) -> x |
1234 |
| -(Sub32F x (Const32F [0])) -> x |
1235 |
| -(Sub64F x (Const64F [0])) -> x |
1236 |
| -(Mul32F x (Const32F [f2i(1)])) -> x |
1237 |
| -(Mul64F x (Const64F [f2i(1)])) -> x |
| 1211 | +(Add(32|64)F x (Const(32|64)F [0])) -> x |
| 1212 | +(Sub(32|64)F x (Const(32|64)F [0])) -> x |
| 1213 | + |
| 1214 | +(Mul(32|64)F x (Const(32|64)F [f2i(1)])) -> x |
1238 | 1215 | (Mul32F x (Const32F [f2i(-1)])) -> (Neg32F x)
|
1239 | 1216 | (Mul64F x (Const64F [f2i(-1)])) -> (Neg64F x)
|
1240 | 1217 | (Mul32F x (Const32F [f2i(2)])) -> (Add32F x x)
|
1241 | 1218 | (Mul64F x (Const64F [f2i(2)])) -> (Add64F x x)
|
| 1219 | + |
1242 | 1220 | (Div32F x (Const32F <t> [c])) && reciprocalExact32(float32(i2f(c))) -> (Mul32F x (Const32F <t> [f2i(1/i2f(c))]))
|
1243 | 1221 | (Div64F x (Const64F <t> [c])) && reciprocalExact64(i2f(c)) -> (Mul64F x (Const64F <t> [f2i(1/i2f(c))]))
|
1244 | 1222 |
|
|
0 commit comments