rgbds
rgbds copied to clipboard
Operations that always have the same value can be assembly-time constant
-
Foo * 0
is always0
-
Foo & 0
is always0
-
Foo - Foo
is always0
-
Foo ^ Foo
is always0
These could be constant even when Foo
is floating and unaligned.
-
Foo + ~Foo
andFoo | ~Foo
are always-1
-
Foo + -Foo
is always0
-
Foo * 1
is alwaysFoo
;Foo * -1
is always-Foo
(helps reducing into the other cases)
...and so on
Reducing those will prove very difficult, however. (And time-consuming if the comparison strategy is to compare the RPN buffers.)
I see what you mean, assuming Foo
can be literally any expression, not just a symbol. In that case only expr * 0
and expr & 0
would be feasible.
And besides, I have considered those a long time ago, but I think they are too fringe to be worth special-casing. #965 made sense to be able to poll for alignment, but I can't see use cases for these.
And besides, I have considered those a long time ago, but I think they are too fringe to be worth special-casing. #965 made sense to be able to poll for alignment, but I can't see use cases for these.
The best use case I can think of is !cond * val0 + !!cond * val1
as a cheap inline conditional. (Yes, I know, true conditional expressions are coming someday, but someday is far away.)
Base the implementation for expr * 0
and expr & 0
on #976.
Closing as not worth the complexity.