[LLVMdev] DAG optimization and lowering algorithm

Eli Friedman eli.friedman at gmail.com
Tue Feb 7 00:15:17 PST 2012


On Mon, Feb 6, 2012 at 11:54 PM, Demikhovsky, Elena
<elena.demikhovsky at intel.com> wrote:
> Hi,
>
> I'm trying to build code for very short function and I encounter with a problem (or bug) in DAG selection algotithm.
> I have a node that was created in Combine(BeforeLegalizeTypes) and should be optimized in Combine(AfterLegalizeTypes). But LegalizeTypes() did not change anything and Combine(AfterLegalizeTypes) was not called.
> Vector legalization that comes afterwards just scalarized the operation.
>
> SelectionDAGISel::CodeGenAndEmitDAG()
> ..
>   CurDAG->Combine(BeforeLegalizeTypes, *AA, OptLevel);
>
>   bool Changed;
>   Changed = CurDAG->LegalizeTypes();
>
>   if (Changed) {
>      CurDAG->Combine(AfterLegalizeTypes, *AA, OptLevel);
>    }
>
> The problem does not exist if the function is bigger and something was changed on LegalizeTypes() stage.
>
> I think that Combine(AfterLegalizeTypes) should be called anyway, even if LegalizeTypes() did not change anything.

We skip the extra run as a performance optimization... we really don't
want extra runs of DAGCombine if we can avoid it.  If there is some
optimization that currently only runs after type legalization, perhaps
we can change it?

-Eli




More information about the llvm-dev mailing list