Constant propagation with basic unboxed arithmetic instructions
I have a program that generates the following core:
main = case t of t0
0## -> ...
DEFAULT -> case t0 -# 1## of t1
0## -> ...
DEFAUT -> case t1 -# 1## of t2
0## -> ...
DEFAULT -> case t2 -# 1## of _
0## -> ...
DEFAULT -> ...
I think it would be possible to implement constant propagation to get:
main = case t of _
0## -> ...
1## -> ...
2## -> ...
3## -> ...
DEFAULT -> ...
If I'm not mistaken, to do that we could replace occurences of:
case t -# k# of _
n0# -> ...
n1# -> ...
...
DEFAULT -> f
with:
case t of _
(n0#+k#) -> ... -- (ni#+k#) statically computed
(n1#+k#) -> ...
...
DEFAULT -> f
Any guidance on how to implement that would be appreciated.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.0.1 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |