Craig Topper via llvm-dev
2021-Feb-18 00:46 UTC
[llvm-dev] Potentially unsafe loop optimization
What version of llvm are you using? Godbolt is showing trunk and llvm 10 have a conditional branch, llvm 11 does not. ~Craig On Wed, Feb 17, 2021 at 4:41 PM Richard Kenner via llvm-dev < llvm-dev at lists.llvm.org> wrote:> > Long story short, from what I can see there is no miscompilation > > or change in semantics for that matter. > > So why does the .s file not contain the loop exit test? > > .text > .file "c26006a.adb" > .globl _ada_c26006a # -- Begin function > _ada_c26006a > .p2align 4, 0x90 > .type _ada_c26006a, at function > _ada_c26006a: # @_ada_c26006a > .cfi_startproc > # %bb.0: # %entry > pushq %rbx > .cfi_def_cfa_offset 16 > subq $32, %rsp > .cfi_def_cfa_offset 48 > .cfi_offset %rbx, -16 > movw $8257, 16(%rsp) # imm = 0x2041 > movb $49, 18(%rsp) > movw $8257, (%rsp) # imm = 0x2041 > movb $50, 2(%rsp) > xorl %ebx, %ebx > jmp .LBB0_1 > .p2align 4, 0x90 > .LBB0_3: # %loop.cond.iter > # in Loop: Header=BB0_1 Depth=1 > incb %bl > .LBB0_1: # %loop.cond > # =>This Inner Loop Header: Depth=1 > movb %bl, 17(%rsp) > movb %bl, 1(%rsp) > movzwl (%rsp), %eax > xorw 16(%rsp), %ax > movzbl 2(%rsp), %ecx > xorb 18(%rsp), %cl > movzbl %cl, %ecx > orw %ax, %cx > jne .LBB0_3 > # %bb.2: # in Loop: Header=BB0_1 Depth=1 > callq abort > jmp .LBB0_3 > .Lfunc_end0: > .size _ada_c26006a, .Lfunc_end0-_ada_c26006a > .cfi_endproc > # -- End function > .section ".note.GNU-stack","", at progbits > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210217/bae16d8c/attachment.html>
Johannes Doerfert via llvm-dev
2021-Feb-18 00:57 UTC
[llvm-dev] Potentially unsafe loop optimization
llc generates the return in all version I tried: https://godbolt.org/z/oh3fqh On 2/17/21 6:46 PM, Craig Topper wrote:> What version of llvm are you using? Godbolt is showing trunk and llvm 10 > have a conditional branch, llvm 11 does not. > > ~Craig > > > On Wed, Feb 17, 2021 at 4:41 PM Richard Kenner via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >>> Long story short, from what I can see there is no miscompilation >>> or change in semantics for that matter. >> So why does the .s file not contain the loop exit test? >> >> .text >> .file "c26006a.adb" >> .globl _ada_c26006a # -- Begin function >> _ada_c26006a >> .p2align 4, 0x90 >> .type _ada_c26006a, at function >> _ada_c26006a: # @_ada_c26006a >> .cfi_startproc >> # %bb.0: # %entry >> pushq %rbx >> .cfi_def_cfa_offset 16 >> subq $32, %rsp >> .cfi_def_cfa_offset 48 >> .cfi_offset %rbx, -16 >> movw $8257, 16(%rsp) # imm = 0x2041 >> movb $49, 18(%rsp) >> movw $8257, (%rsp) # imm = 0x2041 >> movb $50, 2(%rsp) >> xorl %ebx, %ebx >> jmp .LBB0_1 >> .p2align 4, 0x90 >> .LBB0_3: # %loop.cond.iter >> # in Loop: Header=BB0_1 Depth=1 >> incb %bl >> .LBB0_1: # %loop.cond >> # =>This Inner Loop Header: Depth=1 >> movb %bl, 17(%rsp) >> movb %bl, 1(%rsp) >> movzwl (%rsp), %eax >> xorw 16(%rsp), %ax >> movzbl 2(%rsp), %ecx >> xorb 18(%rsp), %cl >> movzbl %cl, %ecx >> orw %ax, %cx >> jne .LBB0_3 >> # %bb.2: # in Loop: Header=BB0_1 Depth=1 >> callq abort >> jmp .LBB0_3 >> .Lfunc_end0: >> .size _ada_c26006a, .Lfunc_end0-_ada_c26006a >> .cfi_endproc >> # -- End function >> .section ".note.GNU-stack","", at progbits >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >>