<div dir="ltr"><div>Certainly wouldn't hurt to try and seems like a better option for what you want, though now I'm interested in the limitations of hasSideEffects and how the scheduler treats this exactly. let me know if this works out for you, curious, thanks.</div><div><br></div><div>-Ryan</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 22, 2016 at 3:48 PM, Phil Tomson <span dir="ltr"><<a href="mailto:phil.a.tomson@gmail.com" target="_blank">phil.a.tomson@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>ok, we do have hasSideEffects set on the fence instruction. I wonder if we should also set isBarrier ? <br><span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888">Phil<br></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 22, 2016 at 12:17 PM, Matt Arsenault <span dir="ltr"><<a href="mailto:arsenm2@gmail.com" target="_blank">arsenm2@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><div><div><blockquote type="cite"><div>On Aug 22, 2016, at 11:54, Phil Tomson <<a href="mailto:phil.a.tomson@gmail.com" target="_blank">phil.a.tomson@gmail.com</a>> wrote:</div><br><div><br><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">On Mon, Aug 22, 2016 at 11:40 AM, Matt Arsenault<span> </span><span dir="ltr"><<a href="mailto:arsenm2@gmail.com" target="_blank">arsenm2@gmail.com</a>></span><span> </span><wbr>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div><br>> On Aug 22, 2016, at 11:20, Phil Tomson via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>><br>> We improved our instruction itineraries and now we're seeing our testcases for fence instructions break.<br>><br>> For example, we have this testcase:<br>><br>> @write_me = external global i32<br>> @read_me = external global i32<br>><br>> ; Function Attrs: nounwind<br>> define i32 @xstg_intrinsic(i32 %foo) #0 {<br>> entry:<br>> ; CHECK: store r0, r1, 0, 32<br>> ; CHECK-NEXT: fence 2<br>> %foo.addr = alloca i32, align 4<br>> store i32 %foo, i32* %foo.addr, align 4<br>> %0 = load i32* %foo.addr, align 4<br>> store volatile i32 %0, i32* @write_me, align 4<br>> call void @llvm.xstg.memory.barrier(i32 2, i8 0)<br>> %1 = load volatile i32* @read_me, align 4<br>> ret i32 %1<br>> }<br>><br>> Prior to adding our instruction itineraries the code generated was:<br>><br>> xstg_intrinsic: # @xstg_intrinsic<br>> # BB#0: # %entry<br>> subI r509, r509, 16, 64<br>> store r510, r509, 0, 64<br>> bitop1 r510, r509, 0, OR, 64<br>> store r0, r510, 12, 32<br>> movimm r1, %hi(write_me), 64<br>> movimmshf32 r1, r1, %lo(write_me)<br>> store r0, r1, 0, 32<br>> fence 2<br>> movimm r0, %hi(read_me), 64<br>> movimmshf32 r0, r0, %lo(read_me)<br>> load r1, r0, 0, 32<br>> bitop1 r509, r510, 0, OR, 64<br>> load r510, r509, 0, 64<br>> addI r509, r509, 16, 64<br>> jabs r511<br>><br>> Note the separation between the store prior to the fence and the code that comes after.<br>><br>> Now that we've got itineraries in place we see:<br>><br>> subI r509, r509, 16, 64<br>> store r510, r509, 0, 64<br>> bitop1 r510, r509, 0, OR, 64<br>> movimm r1, %hi(write_me), 64<br>> store r0, r510, 12, 32<br>> movimmshf32 r1, r1, %lo(write_me)<br>> movimm r2, %hi(read_me), 64<br>> store r0, r1, 0, 32<br>> movimmshf32 r2, r2, %lo(read_me)<br>> fence 2<br>> load r1, r2, 0, 32<br>> bitop1 r509, r510, 0, OR, 64<br>> load r510, r509, 0, 64<br>> addI r509, r509, 16, 64<br>> jabs r511<br>><br>> the movimm which sets up the address for the load has been moved up prior to the fence.<br>><br>> Is there a way to indicate in the itinerary that position of the fence should be fixed - no instruction reordering "through" the fence/barrier?<br>><br>> Phil<br></div></div>> ______________________________<wbr>_________________<br>> LLVM Developers mailing list<br>><span> </span><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>><span> </span><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank" rel="noreferrer">http://lists.llvm.org/cgi-bi<wbr>n/mailman/listinfo/llvm-dev</a><br><br><br>I don’t see a change relative to the memory instructions.<span> </span></blockquote><div><br></div><div>True, we may be being a bit too skiddish about this... perhaps the solution is to change the testcase so that we can ensure that the relative order between the store and the fence has been preserved.<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Do you mean you want this to avoid scheduling of any instruction around any other? Does the instruction have isSideEffects set on it?</blockquote><div><br></div><div>Where can I find information about isSideEffects? Googling "LLVm isSideEffects" didnt' reveal anything that looked relevant.<br></div></div></div></blockquote><div><br></div></div></div><div>hasSideEffects. Look in Target.td / TargetInstrInfo.h. For a memory fence I think it should be sufficient to set mayLoad = 1, mayStore = 1 and not give the fence any memory operands</div><span><br><blockquote type="cite"><div><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">I think the fallback if that isn’t enough is to override TargetInstrInfo::isSchedulingB<wbr>oundary<br><span><font color="#888888"><br></font></span></blockquote><div><br></div><div>Thanks, I'll look at that in other targets.<br><br></div><div>Phil<span> </span><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span><font color="#888888">-Matt</font></span></blockquote></div></div></blockquote></span></div><br></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>