Skip to content

Commit

Permalink
compiler: --opt-math convers modulo by 2 expressions to equivalent bi…
Browse files Browse the repository at this point in the history
…twise operation
  • Loading branch information
mertcandav committed Mar 18, 2024
1 parent 9725d49 commit ccc8aa0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/julec/optimizing/expr.jule
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ impl ExprOptimizer {
c.set_u64(x)
ret
}
| TokenKind.Percent:
let mut c = (&Const)(m.right.model)
let d = c.as_f64()
if d == 2 {
m.op.kind = TokenKind.Amper
c.set_i64(1)
}
}
*self.model = &UnsafeBinopExprModel{
node: m,
Expand Down

0 comments on commit ccc8aa0

Please sign in to comment.