#5245: Cmm optimizer: propagate constants across basic block boundaries
---------------------------------+------------------------------------------
Reporter: tibbe | Owner:
Type: feature request | Status: new
Priority: normal | Component: Compiler
Version: 7.0.3 | Keywords:
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
The new constant propagation pass optimizes
{{{
fn
{
bits64 a, b;
a = 1;
b = a + a;
RET_N(b);
}
}}}
as
{{{
fn() { []
}
cc: R1 = 2;
jump (I64[Sp + 0]) ();
}
}}}
which is good. However, it fails to propagate the constants across a basic
block boundary. For example, the following code
{{{
fn
{
bits64 a, b;
a = 1;
lbl:
b = a + a;
RET_N(b);
}
}}}
gets optimized as
{{{
n() { []
}
cd: _cf::I64 = 1;
goto ce;
ce: R1 = _cf::I64 + _cf::I64;
jump (I64[Sp + 0]) ();
}
}}}
To make this work we should ideally work with a better representation of
instructions and their use sites than currently used in `CmmOpt.hs`. For
example, see how simple this optimization pass is to implement in LLVM:
http://llvm.org/viewvc/llvm-
project/llvm/trunk/lib/Transforms/Scalar/ConstantProp.cpp?view=markup
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5245>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs