[LLVMdev] SelectionDAG legality: isel creating cycles

David Greene dag at cray.com
Mon Feb 22 13:48:15 PST 2010


On Monday 22 February 2010 15:44:56 Anton Korobeynikov wrote:
> Hello, David
>
> > Ah, isLegalToFold saves us on trunk.  But we lose folding due to
> > prefetching, which is unfortunate.
> >
> > I am seeing the error with 2.5 (yes, we are upgrading!).
> >
> > I guess I'll have to backport some of the isLogalToFold logic.
>
> There was x86-only code at pre-2.6 times which was later moved into
> generic hook named "isLegalAndProfitableToFold". You might want to
> backport just that part.

I found the problem.  It's a bug in 2.5:

/// SelectScalarSSELoad - Match a scalar SSE load.  In particular, we want to
/// match a load whose top elements are either undef or zeros.  The load 
flavor
/// is derived from the type of N, which is either v4f32 or v2f64.
bool X86DAGToDAGISel::SelectScalarSSELoad(SDValue Op, SDValue Pred,
                                          SDValue N, SDValue &Base,
                                          SDValue &Scale, SDValue &Index,
                                          SDValue &Disp, SDValue &InChain,
                                          SDValue &OutChain) {
  if (N.getOpcode() == ISD::SCALAR_TO_VECTOR) {
    InChain = N.getOperand(0).getValue(1);
    if (ISD::isNON_EXTLoad(InChain.getNode()) &&
        InChain.getValue(0).hasOneUse() &&
        N.hasOneUse() &&
        // Cray: Bug 757517 (fixed in 2.7, possibly 2.6)
        IsLegalAndProfitableToFold(N.getOperand(0).getNode(), Pred.getNode(), 
Op.getNode())) {

The call used to be:

IsLegalAndProfitableToFold(N.getNode(), Pred.getNode(), Op.getNode()))

so it was checking the wrong thing for legality.

Thanks for the help, everyone!

                                          -Dave





More information about the llvm-dev mailing list