<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 13, 2016 at 12:14 PM, Matthias Braun <span dir="ltr"><<a href="mailto:mbraun@apple.com" target="_blank">mbraun@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">You should be able to get the related MachineInstrs (SDNode->Instr). If you have different instructions for different address spaces you can just check the opcode, otherwise you can check if the instructions have MachineMemOperands which contains additional information about the memory access including the address space involved.<br></blockquote><div><br></div><div>I tried the latter suggestion since we don't have different load instructions for different address spaces and noticed that all of the address spaces that get returned are 0 - even though the .ll file shows loads from different addressspaces like:<br><br> %0 = load i32 addrspace(4)* @answer, align 4<br>  store i32 %0, i32* @xint, align 4<br>  %1 = load i32 addrspace(2)* @seven, align 4<br>  store i32 %1, i32* %bint, align 4<br>  %2 = load i32 addrspace(3)* @two, align 4<br><br></div><div>This is what I tried:<br><br>unsigned<br>    XTargetInstrInfo::getInstrLatency(const InstrItineraryData *ItinData,<br>                                           const MachineInstr *MI,<br>                                           unsigned *PredCost) const {<br><br>   int Latency = XTargetGenInstrInfo::getInstrLatency(ItinData, MI, PredCost);<br> <br>      std::string type_str;<br>      llvm::raw_string_ostream rso(type_str);<br>      MI->print(rso);<br>      if(PredCost) {<br>      std::cout << "    PredCost: " << *PredCost << "\n";<br>      }<br>         MachineInstr::mmo_iterator MMOI;<br>         for(MMOI = MI->memoperands_begin(); MMOI != MI->memoperands_end(); ++MMOI) {<br>           std::cout << "     AddressSpace:" << ((*MMOI)->getAddrSpace()) << "\n";<br>         }<br>    return Latency;<br>}<br><br></div><div><br></div><div>Phil<br></div><div><br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
- Matthias<br>
<div><div class="h5"><br>
> On Jun 13, 2016, at 11:55 AM, Phil Tomson via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
><br>
> We'd like to be able to vary the latency of our load instructions based on what address space is being loaded from. I was thinking I could do this by overriding getOperandLatency in our target, but I'm wondering if the addrspace info is available when instructions are scheduled?<br>
><br>
> For example, I have this in our llvm IR:<br>
><br>
>   %0 = load i32 addrspace(4)* @answer, align 4<br>
>   store i32 %0, i32* @xint, align 4<br>
>   %1 = load i32 addrspace(2)* @seven, align 4<br>
>   store i32 %1, i32* %bint, align 4<br>
>   %2 = load i32 addrspace(3)* @two, align 4<br>
>   store i32 %2, i32* %cint, align 4<br>
><br>
> Loading from addrspace(4) or addrspace(3) should have a much higher latency than loading from addrspace(2) or addrspace(1).  But is that information available to the instruction scheduler in our overridden getOperandLatency method?<br>
><br>
> Phil<br>
><br>
</div></div>> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br>
</blockquote></div><br></div></div>