<div dir="ltr"><div><div><div><div><div><div><div>We improved our instruction itineraries and now we're seeing our testcases for fence instructions break.<br><br></div>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></div>Prior to adding our instruction itineraries the code generated was:<br><br>xstg_intrinsic:               <wbr>          # @xstg_intrinsic<br># BB#0:                         <wbr>        # %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)<span><br>    store        r0, r1, 0, 32<br></span>    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></div>Note the separation between the store prior to the fence and the code that comes after.<br><br></div>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<span><br>    store        r0, r1, 0, 32<br></span>    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></div>the movimm which sets up the address for the load has been moved up prior to the fence.  <br><br></div>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></div>Phil<br></div>