diff options
Diffstat (limited to 'ir.c')
| -rw-r--r-- | ir.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -568,6 +568,12 @@ Node *node_idealize(Node *n, Proc *p, Lexer *l) { if (node_eql_i64(CDR(n), 0)) { lex_error_at(l, CDR(n)->src_pos, LE_ERROR, S("divisor always evaluates to zero")); } + { + int po2; + if (T(CDR(n), N_LIT) && CDR(n)->val.type.t == T_INT && (po2 = u64_power_of_2(CDR(n)->val.u))) {; + return NODE(N_OP_SHR, CAR(n), node_new_lit_i64(p, po2)); + } + } break; case N_OP_OR: if (same) return CAR(n); |
