Skip to content

Commit

Permalink
Optimize OMRCAS8Helper
Browse files Browse the repository at this point in the history
This patch reduces the number of instructions used
to implement OMRCAS8Helper by reducing register
shuffling and removing the unecessary stdcx that
is performed when the comparison fails.

Signed-off-by: Younes Manton <[email protected]>
  • Loading branch information
ymanton committed Sep 11, 2018
1 parent 288cb97 commit 1ebd8d7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 34 deletions.
29 changes: 13 additions & 16 deletions util/omrutil/unix/aix/32/cas8help.s
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
.set r29,29
.set r30,30
.set r31,31
.set cr0,0
.toc
TOC.static: .tc .static[tc],_static[ro]
.csect _static[ro]
Expand Down Expand Up @@ -80,23 +81,19 @@ TOC.OMRCAS8Helper: .tc .OMRCAS8Helper[tc],OMRCAS8Helper[ds]
#
# r3 = high part of read value
# r4 = low part of read value
ori r12, r3, 0
ori r8, r4, 0
.machine "push"
.machine "ppc64"
rldimi r4, r5, 32, 0
rldimi r6, r7, 32, 0
loop:
.long 0x7d2060a8 # ldarx r9, 0, r12
.long 0x79230022 # srdi r3, r9, 32
ori r4, r9, 0
ori r10, r8, 0
ori r11, r6, 0
.long 0x78aa000e # rldimi r10, r5, 32, 0
.long 0x78eb000e # rldimi r11, r7, 32, 0
.long 0x7c295040 # cmpl 0, 1, r9, r10
bne fail
.long 0x7d6061ad # stdcx. r11, 0, r12
bne loop
blr
ldarx r8, 0, r3
cmpld cr0, r8, r4
bne- fail
stdcx. r6, 0, r3
bne- loop
fail:
.long 0x7d2061ad # stdcx. r9, 0, r12
bne loop
mr r4, r8
srdi r3, r8, 32
blr
.machine "pop"
endproc.OMRCAS8Helper:
30 changes: 12 additions & 18 deletions util/omrutil/unix/linux/ppc/32/cas8help.s
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
.set r29,29
.set r30,30
.set r31,31
.set cr0,0
.section ".rodata"
.global OMRCAS8Helper
.type OMRCAS8Helper@function
Expand All @@ -70,22 +71,15 @@ OMRCAS8Helper:
#
# r3 = high part of read value
# r4 = low part of read value
ori r12, r3, 0
ori r8, r4, 0
loop:
ldarx r9, 0, r12
srdi r3, r9, 32
ori r4, r9, 0
ori r10, r8, 0
ori r11, r6, 0
rldimi r10, r5, 32, 0
rldimi r11, r7, 32, 0
cmpl cr0, 1, r9, r10
bne fail
stdcx. r11, 0, r12
bne loop
blr
fail:
stdcx. r9, 0, r12
bne loop
rldimi r4, r5, 32, 0
rldimi r6, r7, 32, 0
0:
ldarx r8, 0, r3
cmpld cr0, r8, r4
bne- 1f
stdcx. r6, 0, r3
bne- 0b
1:
mr r4, r8
srdi r3, r8, 32
blr

0 comments on commit 1ebd8d7

Please sign in to comment.