mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-02 00:37:09 +00:00
Atomics: switch direction of cmpxchg comparison
This has two benefits: it makes the result more suitable for direct insertaion into the struct to emulate the new cmpxchg, and it means the name we give the instruction matches its actual effect better. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210916 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
61bc72e9ae
commit
6b3ed2b821
@ -283,9 +283,9 @@ bool AtomicExpandLoadLinked::expandAtomicCmpXchg(AtomicCmpXchgInst *CI) {
|
||||
Builder.SetInsertPoint(TryStoreBB);
|
||||
Value *StoreSuccess = TLI->emitStoreConditional(
|
||||
Builder, CI->getNewValOperand(), Addr, MemOpOrder);
|
||||
Value *TryAgain = Builder.CreateICmpNE(
|
||||
StoreSuccess = Builder.CreateICmpEQ(
|
||||
StoreSuccess, ConstantInt::get(Type::getInt32Ty(Ctx), 0), "success");
|
||||
Builder.CreateCondBr(TryAgain, LoopBB, BarrierBB);
|
||||
Builder.CreateCondBr(StoreSuccess, BarrierBB, LoopBB);
|
||||
|
||||
// Make sure later instructions don't get reordered with a fence if necessary.
|
||||
Builder.SetInsertPoint(BarrierBB);
|
||||
|
@ -234,8 +234,8 @@ define i8 @test_cmpxchg_i8_seqcst_seqcst(i8* %ptr, i8 %desired, i8 %newval) {
|
||||
; CHECK: [[TRY_STORE]]:
|
||||
; CHECK: [[NEWVAL32:%.*]] = zext i8 %newval to i32
|
||||
; CHECK: [[TRYAGAIN:%.*]] = call i32 @llvm.arm.strex.p0i8(i32 [[NEWVAL32]], i8* %ptr)
|
||||
; CHECK: [[TST:%.*]] = icmp ne i32 [[TRYAGAIN]], 0
|
||||
; CHECK: br i1 [[TST]], label %[[LOOP]], label %[[BARRIER:.*]]
|
||||
; CHECK: [[TST:%.*]] = icmp eq i32 [[TRYAGAIN]], 0
|
||||
; CHECK: br i1 [[TST]], label %[[BARRIER:.*]], label %[[LOOP]]
|
||||
|
||||
; CHECK: [[BARRIER]]:
|
||||
; CHECK: [[SUCCESS:%.*]] = phi i1 [ true, %[[TRY_STORE]] ], [ false, %[[LOOP]] ]
|
||||
@ -264,8 +264,8 @@ define i16 @test_cmpxchg_i16_seqcst_monotonic(i16* %ptr, i16 %desired, i16 %newv
|
||||
; CHECK: [[TRY_STORE]]:
|
||||
; CHECK: [[NEWVAL32:%.*]] = zext i16 %newval to i32
|
||||
; CHECK: [[TRYAGAIN:%.*]] = call i32 @llvm.arm.strex.p0i16(i32 [[NEWVAL32]], i16* %ptr)
|
||||
; CHECK: [[TST:%.*]] = icmp ne i32 [[TRYAGAIN]], 0
|
||||
; CHECK: br i1 [[TST]], label %[[LOOP]], label %[[BARRIER:.*]]
|
||||
; CHECK: [[TST:%.*]] = icmp eq i32 [[TRYAGAIN]], 0
|
||||
; CHECK: br i1 [[TST]], label %[[BARRIER:.*]], label %[[LOOP]]
|
||||
|
||||
; CHECK: [[BARRIER]]:
|
||||
; CHECK: fence seq_cst
|
||||
@ -292,8 +292,8 @@ define i32 @test_cmpxchg_i32_acquire_acquire(i32* %ptr, i32 %desired, i32 %newva
|
||||
|
||||
; CHECK: [[TRY_STORE]]:
|
||||
; CHECK: [[TRYAGAIN:%.*]] = call i32 @llvm.arm.strex.p0i32(i32 %newval, i32* %ptr)
|
||||
; CHECK: [[TST:%.*]] = icmp ne i32 [[TRYAGAIN]], 0
|
||||
; CHECK: br i1 [[TST]], label %[[LOOP]], label %[[BARRIER:.*]]
|
||||
; CHECK: [[TST:%.*]] = icmp eq i32 [[TRYAGAIN]], 0
|
||||
; CHECK: br i1 [[TST]], label %[[BARRIER:.*]], label %[[LOOP]]
|
||||
|
||||
; CHECK: [[BARRIER]]:
|
||||
; CHECK: [[SUCCESS:%.*]] = phi i1 [ true, %[[TRY_STORE]] ], [ false, %[[LOOP]] ]
|
||||
@ -331,8 +331,8 @@ define i64 @test_cmpxchg_i64_monotonic_monotonic(i64* %ptr, i64 %desired, i64 %n
|
||||
; CHECK: [[NEWHI:%.*]] = trunc i64 [[NEWHI_TMP]] to i32
|
||||
; CHECK: [[PTR8:%.*]] = bitcast i64* %ptr to i8*
|
||||
; CHECK: [[TRYAGAIN:%.*]] = call i32 @llvm.arm.strexd(i32 [[NEWLO]], i32 [[NEWHI]], i8* [[PTR8]])
|
||||
; CHECK: [[TST:%.*]] = icmp ne i32 [[TRYAGAIN]], 0
|
||||
; CHECK: br i1 [[TST]], label %[[LOOP]], label %[[BARRIER:.*]]
|
||||
; CHECK: [[TST:%.*]] = icmp eq i32 [[TRYAGAIN]], 0
|
||||
; CHECK: br i1 [[TST]], label %[[BARRIER:.*]], label %[[LOOP]]
|
||||
|
||||
; CHECK: [[BARRIER]]:
|
||||
; CHECK-NOT: fence
|
||||
|
@ -96,8 +96,8 @@ define i8 @test_cmpxchg_i8_seqcst_seqcst(i8* %ptr, i8 %desired, i8 %newval) {
|
||||
; CHECK: [[TRY_STORE]]:
|
||||
; CHECK: [[NEWVAL32:%.*]] = zext i8 %newval to i32
|
||||
; CHECK: [[TRYAGAIN:%.*]] = call i32 @llvm.arm.stlex.p0i8(i32 [[NEWVAL32]], i8* %ptr)
|
||||
; CHECK: [[TST:%.*]] = icmp ne i32 [[TRYAGAIN]], 0
|
||||
; CHECK: br i1 [[TST]], label %[[LOOP]], label %[[BARRIER:.*]]
|
||||
; CHECK: [[TST:%.*]] = icmp eq i32 [[TRYAGAIN]], 0
|
||||
; CHECK: br i1 [[TST]], label %[[BARRIER:.*]], label %[[LOOP]]
|
||||
|
||||
; CHECK: [[BARRIER]]:
|
||||
; CHECK: [[SUCCESS:%.*]] = phi i1 [ true, %[[TRY_STORE]] ], [ false, %[[LOOP]] ]
|
||||
@ -126,8 +126,8 @@ define i16 @test_cmpxchg_i16_seqcst_monotonic(i16* %ptr, i16 %desired, i16 %newv
|
||||
; CHECK: [[TRY_STORE]]:
|
||||
; CHECK: [[NEWVAL32:%.*]] = zext i16 %newval to i32
|
||||
; CHECK: [[TRYAGAIN:%.*]] = call i32 @llvm.arm.stlex.p0i16(i32 [[NEWVAL32]], i16* %ptr)
|
||||
; CHECK: [[TST:%.*]] = icmp ne i32 [[TRYAGAIN]], 0
|
||||
; CHECK: br i1 [[TST]], label %[[LOOP]], label %[[BARRIER:.*]]
|
||||
; CHECK: [[TST:%.*]] = icmp eq i32 [[TRYAGAIN]], 0
|
||||
; CHECK: br i1 [[TST]], label %[[BARRIER:.*]], label %[[LOOP]]
|
||||
|
||||
; CHECK: [[BARRIER]]:
|
||||
; CHECK-NOT: fence
|
||||
@ -154,8 +154,8 @@ define i32 @test_cmpxchg_i32_acquire_acquire(i32* %ptr, i32 %desired, i32 %newva
|
||||
|
||||
; CHECK: [[TRY_STORE]]:
|
||||
; CHECK: [[TRYAGAIN:%.*]] = call i32 @llvm.arm.strex.p0i32(i32 %newval, i32* %ptr)
|
||||
; CHECK: [[TST:%.*]] = icmp ne i32 [[TRYAGAIN]], 0
|
||||
; CHECK: br i1 [[TST]], label %[[LOOP]], label %[[BARRIER:.*]]
|
||||
; CHECK: [[TST:%.*]] = icmp eq i32 [[TRYAGAIN]], 0
|
||||
; CHECK: br i1 [[TST]], label %[[BARRIER:.*]], label %[[LOOP]]
|
||||
|
||||
; CHECK: [[BARRIER]]:
|
||||
; CHECK: [[SUCCESS:%.*]] = phi i1 [ true, %[[TRY_STORE]] ], [ false, %[[LOOP]] ]
|
||||
@ -193,8 +193,8 @@ define i64 @test_cmpxchg_i64_monotonic_monotonic(i64* %ptr, i64 %desired, i64 %n
|
||||
; CHECK: [[NEWHI:%.*]] = trunc i64 [[NEWHI_TMP]] to i32
|
||||
; CHECK: [[PTR8:%.*]] = bitcast i64* %ptr to i8*
|
||||
; CHECK: [[TRYAGAIN:%.*]] = call i32 @llvm.arm.strexd(i32 [[NEWLO]], i32 [[NEWHI]], i8* [[PTR8]])
|
||||
; CHECK: [[TST:%.*]] = icmp ne i32 [[TRYAGAIN]], 0
|
||||
; CHECK: br i1 [[TST]], label %[[LOOP]], label %[[BARRIER:.*]]
|
||||
; CHECK: [[TST:%.*]] = icmp eq i32 [[TRYAGAIN]], 0
|
||||
; CHECK: br i1 [[TST]], label %[[BARRIER:.*]], label %[[LOOP]]
|
||||
|
||||
; CHECK: [[BARRIER]]:
|
||||
; CHECK-NOT: fence
|
||||
|
Loading…
Reference in New Issue
Block a user