Skip to content

Commit

Permalink
Fix swapped CASA operands.
Browse files Browse the repository at this point in the history
Found by SingleSource/UnitTests/AtomicOps.c

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200130 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
stoklund committed Jan 26, 2014
1 parent aa75693 commit 06626a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/Target/Sparc/SparcISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2977,7 +2977,7 @@ SparcTargetLowering::expandAtomicRMW(MachineInstr *MI,
// loop:
// %val = phi %val0, %dest
// %upd = op %val, %rs2
// %dest = cas %addr, %upd, %val
// %dest = cas %addr, %val, %upd
// cmp %val, %dest
// bne loop
// done:
Expand Down Expand Up @@ -3036,7 +3036,7 @@ SparcTargetLowering::expandAtomicRMW(MachineInstr *MI,
}

BuildMI(LoopMBB, DL, TII.get(is64Bit ? SP::CASXrr : SP::CASrr), DestReg)
.addReg(AddrReg).addReg(UpdReg).addReg(ValReg)
.addReg(AddrReg).addReg(ValReg).addReg(UpdReg)
.setMemRefs(MI->memoperands_begin(), MI->memoperands_end());
BuildMI(LoopMBB, DL, TII.get(SP::CMPrr)).addReg(ValReg).addReg(DestReg);
BuildMI(LoopMBB, DL, TII.get(is64Bit ? SP::BPXCC : SP::BCOND))
Expand Down
4 changes: 2 additions & 2 deletions test/CodeGen/SPARC/atomics.ll
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ entry:

; CHECK-LABEL: test_load_add_32
; CHECK: membar
; CHECK: add
; CHECK: cas [%o0]
; CHECK: add [[V:%[gilo][0-7]]], %o1, [[U:%[gilo][0-7]]]
; CHECK: cas [%o0], [[V]], [[U]]
; CHECK: membar
define zeroext i32 @test_load_add_32(i32* %p, i32 zeroext %v) {
entry:
Expand Down

0 comments on commit 06626a6

Please sign in to comment.