Skip to content

Commit 048b74e

Browse files
MrSidimsggojska
authored andcommitted
[SYCL] Update list of barriers after back-to-back elimination (#19700)
Signed-off-by: Sidorov, Dmitry <[email protected]>
1 parent cd7cc4b commit 048b74e

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

llvm/lib/SYCLLowerIR/SYCLOptimizeBarriers.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
// loads from __spirv_BuiltIn GVs)
2525
// – Unknown : any other mayReadOrWriteMemory() (intrinsics, calls,
2626
// generic addrspace)
27-
// * At the same time, build a per-basic block summary of memory accesses:
28-
// - None : only private/constant or no accesses
29-
// - Local : at least one addrspace(3) access
30-
// - Global : at least one addrspace(1/5/6) access (except loads from
31-
// __spirv_BuiltIn globals)
3227
// - Unknown: any other mayReadOrWriteMemory() instruction
3328
//
3429
// 2) **At Entry and At Exit Elimination**
@@ -45,10 +40,6 @@
4540
// – Find the single barrier with the *widest* (ExecScope, MemScope)
4641
// (ignore Unknown).
4742
// – Erase all other barriers (they synchronize nothing).
48-
// If BB summary == None (no local, global or unknown accesses):
49-
// - Find the single barrier with the widest (ExecScope, MemScope)
50-
// ignoring Unknown scopes.
51-
// - Erase all other barriers since they synchronize nothing.
5243
// b) *General Redundancy Check*
5344
// Otherwise we walk the barriers in source order and compare each new
5445
// barrier to the most recent one that is still alive:
@@ -1000,6 +991,11 @@ PreservedAnalyses SYCLOptimizeBarriersPass::run(Function &F,
1000991
Changed |= eliminateBackToBackInBB(BarrierBBPair.first,
1001992
BarrierBBPair.second, BBMemInfo);
1002993

994+
// Refresh the list of barriers after back-to-back elimination.
995+
BarrierPtrs.clear();
996+
for (auto &Pair : BarriersByBB)
997+
for (auto &BD : Pair.second)
998+
BarrierPtrs.push_back(&BD);
1003999
// TODO: hoist 2 barriers with the same predecessor BBs.
10041000

10051001
// In the end eliminate or narrow barriers depending on DT and PDT analyses.

llvm/test/SYCLLowerIR/SYCLOptimizeBarriers/remove-back-to-back-barrier.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ define spir_kernel void @_Z3fooii(i32 %0, i32 %1) {
2727
; CHECK-NEXT: call void @_Z22__spirv_ControlBarrieriii(i32 [[TMP0]], i32 noundef 2, i32 noundef 400)
2828
; CHECK-NEXT: call spir_func void @__itt_offload_wi_resume_wrapper()
2929
; CHECK-NEXT: call spir_func void @__itt_offload_wg_barrier_wrapper()
30-
; CHECK-NEXT: call void @_Z22__spirv_ControlBarrieriii(i32 [[TMP1]], i32 noundef 2, i32 noundef 400)
30+
; CHECK-NEXT: call void @_Z22__spirv_ControlBarrieriii(i32 [[TMP1]], i32 noundef 2, i32 noundef 912)
3131
; CHECK-NEXT: call spir_func void @__itt_offload_wi_resume_wrapper()
3232
; CHECK-NEXT: ret void
3333
;

0 commit comments

Comments
 (0)