49 lines · plain
1; RUN: opt -S -passes=dse < %s | FileCheck %s2 3; We conservative choose to prevent dead store elimination4; across release or stronger fences. It's not required 5; (since the must still be a race on %addd.i), but6; it is conservatively correct. A legal optimization7; could hoist the second store above the fence, and then8; DSE one of them.9define void @test1(ptr %addr.i) {10; CHECK-LABEL: @test111; CHECK: store i32 512; CHECK: fence13; CHECK: store i32 514; CHECK: ret15 store i32 5, ptr %addr.i, align 416 fence release17 store i32 5, ptr %addr.i, align 418 ret void19}20 21; Same as previous, but with different values. If we ever optimize 22; this more aggressively, this allows us to check that the correct23; store is retained (the 'i32 1' store in this case)24define void @test1b(ptr %addr.i) {25; CHECK-LABEL: @test1b26; CHECK: store i32 4227; CHECK: fence release28; CHECK: store i32 129; CHECK: ret30 store i32 42, ptr %addr.i, align 431 fence release32 store i32 1, ptr %addr.i, align 433 ret void34}35 36; We *could* DSE across this fence, but don't. No other thread can37; observe the order of the acquire fence and the store.38define void @test2(ptr %addr.i) {39; CHECK-LABEL: @test240; CHECK: store41; CHECK: fence42; CHECK: store43; CHECK: ret44 store i32 5, ptr %addr.i, align 445 fence acquire46 store i32 5, ptr %addr.i, align 447 ret void48}49