You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, constant propagation on binary expressions requires to know both operands, but there are cases than can be optimized when knowing only one operand:
a + 0 -> a
0 + a -> a
a - 0 -> a
0 - a -> -a
-(-a) -> a
0 * a -> 0
a * 0 -> 0
1 * a -> a
a * 1 -> a
a / 1 -> a (only with integers, because of NaN/inf)
a / a -> 1 (only with integers, because of NaN/inf, no need to handle 0 / 0 as it's UB anyway)
a && true -> a
a && false -> false
a || true -> true
a || false -> a
a < 0 -> false (only with unsigned integers)
a >= 0 -> true (only with unsigned integers)
a == NaN -> false
a == a -> true (only with integers, because of NaN/inf)
a != a -> false (only with integers, because of NaN/inf)
x * po2 -> x << sqrt(po2)
x / po2 -> x >> sqrt(po2)
This will become more important once function inlining is implemented.
The text was updated successfully, but these errors were encountered:
Currently, constant propagation on binary expressions requires to know both operands, but there are cases than can be optimized when knowing only one operand:
a + 0
->a
0 + a
->a
a - 0
->a
0 - a
->-a
-(-a)
->a
0 * a
->0
a * 0
->0
1 * a
->a
a * 1
->a
a / 1
->a
(only with integers, because of NaN/inf)a / a
->1
(only with integers, because of NaN/inf, no need to handle0 / 0
as it's UB anyway)a && true
->a
a && false
->false
a || true
->true
a || false
->a
a < 0
->false
(only with unsigned integers)a >= 0
->true
(only with unsigned integers)a == NaN
->false
a == a
->true
(only with integers, because of NaN/inf)a != a
->false
(only with integers, because of NaN/inf)x * po2
->x << sqrt(po2)
x / po2
->x >> sqrt(po2)
This will become more important once function inlining is implemented.
The text was updated successfully, but these errors were encountered: