https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68908
Bug ID: 68908 Summary: inefficient code for an atomic preincrement on powerpc64le Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- GCC 6.0 for powerpc64le emits the following inefficient code for an atomic increment. (The bogus warning is the subject of bug 68907). $ cat ~/tmp/t.c && /build/gcc-trunk/gcc/xgcc -B /build/gcc-trunk/gcc -O2 -S -Wall -o/dev/stdout ~/tmp/t.c typedef _Atomic int AI; void increment (AI *ai) { ++*ai; } .file "t.c" .machine power8 .abiversion 2 .section ".toc","aw" .section ".text" /home/remote/msebor/tmp/t.c: In function ‘increment’: /home/remote/msebor/tmp/t.c:5:5: warning: right-hand operand of comma expression has no effect [-Wunused-value] ++*ai; ^~~~~ .align 2 .p2align 4,,15 .globl increment .type increment, @function increment: sync lwz 9,0(3) cmpw 7,9,9 bne- 7,$+4 isync extsw 9,9 stw 9,-16(1) .p2align 4,,15 .L6: lwz 8,-16(1) addi 9,9,1 sync .L2: lwarx 10,0,3 cmpw 0,10,8 bne- 0,.L3 stwcx. 9,0,3 bne- 0,.L2 .L3: isync mfcr 9,128 rlwinm 9,9,3,1 beq 0,.L4 stw 10,-16(1) .L4: andi. 10,9,0x1 bnelr- 0 lwa 9,-16(1) b .L6 .long 0 .byte 0,0,0,0,0,0,0,0 .size increment,.-increment .ident "GCC: (GNU) 6.0.0 20151214 (experimental)" .section .note.GNU-stack,"",@progbits Clang 3.8 emits the expected: increment: # @increment .Lfunc_begin0: # BB#0: # %entry li 4, 1 sync .LBB0_1: # %entry # =>This Inner Loop Header: Depth=1 lwarx 5, 0, 3 add 5, 4, 5 stwcx. 5, 0, 3 bne 0, .LBB0_1 # BB#2: # %entry lwsync blr