[LLVMdev] Splitting a load with 2 consumers into 2 loads.

Joseph Pusdesris joe at pusdesris.com
Sat Dec 1 22:20:06 PST 2012


I am writing a target for an odd cisc-like architecture which has no
support for keeping most values in registers.  As such, memory-memory
operations are needed, but for isel to generate a memory-memory the pattern
must be of the form (store (op (load) (load))).

Let's use a simple example to show how this can be problematic:
  %0 = load i32* %a.addr, align 4
  store i32 %0, i32* %other, align 4
  %1 = load i32* %b.addr, align 4
  %add = add i32 %0, %1
----
In this example, the (store (load)) pair -- the first two lines -- will be
matched by isel as a MOVmm.  This will be problematic for the add though,
since the load SDNode will be gone, making that part of the DAG no longer
of the form (add (load) (load)).  To counteract this, I would create 2 load
SDNodes so that both of these patterns can be satisfied.  Does this make
sense?
-Joe




On Sat, Dec 1, 2012 at 11:44 PM, Triple Yang <triple.yang at gmail.com> wrote:

> Hi, Joe.
>
> I am sorry I did not catch your point. Can you provide more details?
>
> Since SDValue/SDNode can be used multiple times, why would you want to
> create two identical objects
> instead of reference to the same one?
>
> 2012/12/2 Joseph Pusdesris <joe at pusdesris.com>:
> > Yes, changing parameters will create a new Node, but is there some way I
> can
> > force a new node with the same parameters?
> > -Joe
> >
> >
> > On Sat, Dec 1, 2012 at 10:57 PM, Triple Yang <triple.yang at gmail.com>
> wrote:
> >>
> >> Hi, Joseph, I guess getLoad() will either search an existed SDValue
> >> *OR* create a new one for a non-existed one depending on real
> >> parameters.
> >>
> >> Since you use exactly the same attributes dupVal/dupNode have, no
> >> doubt getLoad() return the old one.
> >>
> >> I am not sure it's *volatile* that let you get a new result, you might
> >> want to try change some other parameters and check what it turns out.
> >>
> >> Regards.
> >>
> >> 2012/12/2 Joseph Pusdesris <joe at pusdesris.com>
> >> >
> >> > So I think I have made some progress.
> >> > SDValue dupVal  = consumer->getOperand(OpNo);
> >> > LoadSDNode *dupNode = (LoadSDNode*) dupVal.getNode();
> >> >
> >> > SDValue newLoad = CurDAG->getLoad(dupVal.getValueType(),
> >> > dupVal.getDebugLoc(),
> >> >                                dupVal.getOperand(0),
> >> > dupVal.getOperand(1),
> >> >                                dupNode->getPointerInfo(),
> >> >                                dupNode->isVolatile(),
> >> > dupNode->isNonTemporal(),
> >> >                                dupNode->isInvariant(),
> >> > dupNode->getAlignment(),
> >> >                                dupNode->getTBAAInfo(),
> >> > dupNode->getRanges());
> >> > However, my problem now is that it will re-use the same load still.
>  If
> >> > I change something, like setting volatile to true for example, it will
> >> > create a new node, but otherwise it will not.  Any ideas?
> >> > -Joe
> >> >
> >> >
> >> > On Fri, Nov 30, 2012 at 9:55 PM, Joseph Pusdesris <joe at pusdesris.com>
> >> > wrote:
> >> >>
> >> >> Hi, I am writing an llvm target and I need both loads for isel
> reasons,
> >> >> but I am struggling to find the right way.  I have been trying to use
> >> >> DAG.getLoad() to make a copy, then just change the operand in the
> consumers,
> >> >> but I cannot seem to get all of the arguments needed for that
> function in
> >> >> order to make the copy.  Any help would be great, thanks!
> >> >> -Joe
> >> >
> >> >
> >> >
> >> > _______________________________________________
> >> > LLVM Developers mailing list
> >> > LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> >> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> >> >
> >>
> >>
> >>
> >> --
> >> 杨勇勇 (Yang Yongyong)
> >
> >
>
>
>
> --
> 杨勇勇 (Yang Yongyong)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121202/64e07d1f/attachment.html>


More information about the llvm-dev mailing list