https://llvm.org/bugs/show_bug.cgi?id=30621
Bug ID: 30621 Summary: Code generation for __atomic_and_fetch() contains duplicates Product: libraries Version: trunk Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: Common Code Generator Code Assignee: unassignedb...@nondot.org Reporter: yunzhong_...@playstation.sony.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified I was testing with trunk r283366. Here is the test program (atomic.c) short test(short *ptr, short val, int model) { return __atomic_and_fetch(ptr, val, model); } ========================================= Here is the code generated by GCC 4.8.4 test: movzwl (%rdi), %eax movzwl %si, %esi .L2: movl %eax, %edx andl %esi, %edx lock cmpxchgw %dx, (%rdi) jne .L2 movl %edx, %eax ret ========================================= Here is the code generated by clang: test: # @test decl %edx cmpl $4, %edx ja .LBB0_2 jmpq *.LJTI0_0(,%rdx,8) .LBB0_4: # %acquire movw (%rdi), %ax .p2align 4, 0x90 .LBB0_5: # %atomicrmw.start6 # =>This Inner Loop Header: Depth=1 movl %eax, %ecx andl %esi, %ecx # kill: %AX<def> %AX<kill> %EAX<kill> lock cmpxchgw %cx, (%rdi) # kill: %AX<def> %AX<kill> %EAX<def> jne .LBB0_5 jmp .LBB0_12 .LBB0_2: # %monotonic movw (%rdi), %ax .p2align 4, 0x90 .LBB0_3: # %atomicrmw.start # =>This Inner Loop Header: Depth=1 movl %eax, %ecx andl %esi, %ecx # kill: %AX<def> %AX<kill> %EAX<kill> lock cmpxchgw %cx, (%rdi) # kill: %AX<def> %AX<kill> %EAX<def> jne .LBB0_3 jmp .LBB0_12 .LBB0_6: # %release movw (%rdi), %ax .p2align 4, 0x90 .LBB0_7: # %atomicrmw.start12 # =>This Inner Loop Header: Depth=1 movl %eax, %ecx andl %esi, %ecx # kill: %AX<def> %AX<kill> %EAX<kill> lock cmpxchgw %cx, (%rdi) # kill: %AX<def> %AX<kill> %EAX<def> jne .LBB0_7 jmp .LBB0_12 .LBB0_8: # %acqrel movw (%rdi), %ax .p2align 4, 0x90 .LBB0_9: # %atomicrmw.start18 # =>This Inner Loop Header: Depth=1 movl %eax, %ecx andl %esi, %ecx # kill: %AX<def> %AX<kill> %EAX<kill> lock cmpxchgw %cx, (%rdi) # kill: %AX<def> %AX<kill> %EAX<def> jne .LBB0_9 jmp .LBB0_12 .LBB0_10: # %seqcst movw (%rdi), %ax .p2align 4, 0x90 .LBB0_11: # %atomicrmw.start24 # =>This Inner Loop Header: Depth=1 movl %eax, %ecx andl %esi, %ecx # kill: %AX<def> %AX<kill> %EAX<kill> lock cmpxchgw %cx, (%rdi) # kill: %AX<def> %AX<kill> %EAX<def> jne .LBB0_11 .LBB0_12: # %atomic.continue andl %esi, %eax retq It looks to me that many of these loop bodies are identical and can be merged? For example, the .LBB0_5 block, the .LBB0_3 block, the .LBB0_7 block, the .LBB0_9 block and the .LBB0_11 block. Using a size optimization switch like -Os or -Oz does not seem to help. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs