Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 08 Feb 2017 20:34:14 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-ports-bugs@FreeBSD.org
Subject:   [Bug 216770] lang/julia: fails to build with clang 4.0
Message-ID:  <bug-216770-13-gZvZHqLGbe@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-216770-13@https.bugs.freebsd.org/bugzilla/>
References:  <bug-216770-13@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D216770

--- Comment #5 from Dimitry Andric <dim@FreeBSD.org> ---
(In reply to Jan Beich (mail not working) from comment #4)
> -O2 optimizes out (k > 0) check in ratio() from contrib/gdtoa/smisc.c.
> Dimitry, can you confirm?

I don't see it being optimized out. On i386, the assembly becomes:

        .globl  __ratio_D2A
        .p2align        4, 0x90
        .type   __ratio_D2A,@function
__ratio_D2A:                            # @__ratio_D2A
# BB#0:                                 # %entry
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %edi
        pushl   %esi
        andl    $-8, %esp
        subl    $48, %esp
        movl    12(%ebp), %esi
        movl    8(%ebp), %edi
        movl    __stack_chk_guard, %eax
        movl    %eax, 44(%esp)
        leal    20(%esp), %eax
        movl    %eax, 4(%esp)
        movl    %edi, (%esp)
        calll   __b2d_D2A
        fstl    8(%esp)                 # 8-byte Folded Spill
        fstpl   32(%esp)
        leal    16(%esp), %eax
        movl    %eax, 4(%esp)
        movl    %esi, (%esp)
        calll   __b2d_D2A
        fstl    24(%esp)
        movl    20(%esp), %eax
        subl    16(%esp), %eax
        movl    16(%edi), %ecx
        subl    16(%esi), %ecx
        shll    $5, %ecx
        addl    %eax, %ecx
        movl    %ecx, %edx
        sarl    $31, %edx
        leal    (%ecx,%edx), %eax
        xorl    %edx, %eax
        testl   %ecx, %ecx
        jg      .LBB1_1
[... this is the k > 0 comparison ...]
# BB#2:                                 # %entry
        leal    24(%esp), %ecx
        jmp     .LBB1_3
.LBB1_1:
        leal    32(%esp), %ecx
.LBB1_3:                                # %entry
        shll    $20, %eax
        orl     $4, %ecx
        addl    %eax, (%ecx)
        fldl    8(%esp)                 # 8-byte Folded Reload
        fdivp   %st(1)
        movl    __stack_chk_guard, %eax
        cmpl    44(%esp), %eax
        jne     .LBB1_5
# BB#4:                                 # %entry
        leal    -8(%ebp), %esp
        popl    %esi
        popl    %edi
        popl    %ebp
        retl
.LBB1_5:                                # %entry
        fstp    %st(0)
        calll   __stack_chk_fail
.Lfunc_end1:
        .size   __ratio_D2A, .Lfunc_end1-__ratio_D2A

On amd64, it doesn't use jmps, but conditional movs:

        .globl  __ratio_D2A
        .p2align        4, 0x90
        .type   __ratio_D2A,@function
__ratio_D2A:                            # @__ratio_D2A
        .cfi_startproc
# BB#0:                                 # %entry
        pushq   %rbp
.Lcfi8:
        .cfi_def_cfa_offset 16
.Lcfi9:
        .cfi_offset %rbp, -16
        movq    %rsp, %rbp
.Lcfi10:
        .cfi_def_cfa_register %rbp
        pushq   %r14
        pushq   %rbx
        subq    $48, %rsp
.Lcfi11:
        .cfi_offset %rbx, -32
.Lcfi12:
        .cfi_offset %r14, -24
        movq    %rsi, %r14
        movq    %rdi, %rbx
        movq    __stack_chk_guard(%rip), %rax
        movq    %rax, -24(%rbp)
        leaq    -44(%rbp), %rsi
        callq   __b2d_D2A
        movsd   %xmm0, -56(%rbp)        # 8-byte Spill
        movsd   %xmm0, -32(%rbp)
        leaq    -48(%rbp), %rsi
        movq    %r14, %rdi
        callq   __b2d_D2A
        movsd   %xmm0, -40(%rbp)
        movl    -44(%rbp), %eax
        subl    -48(%rbp), %eax
        movl    20(%rbx), %ecx
        subl    20(%r14), %ecx
        shll    $5, %ecx
        addl    %eax, %ecx
        movl    %ecx, %eax
        negl    %eax
        cmovll  %ecx, %eax
        testl   %ecx, %ecx
[... here the value of k is tested ...]
        leaq    -32(%rbp), %rcx
        leaq    -40(%rbp), %rdx
        cmovgq  %rcx, %rdx
[... and here is the conditional move-if-greater ...]
        shll    $20, %eax
        orq     $4, %rdx
        addl    %eax, (%rdx)
        movq    __stack_chk_guard(%rip), %rax
        cmpq    -24(%rbp), %rax
        jne     .LBB1_2
# BB#1:                                 # %entry
        movsd   -56(%rbp), %xmm1        # 8-byte Reload
                                        # xmm1 =3D mem[0],zero
        divsd   %xmm0, %xmm1
        movapd  %xmm1, %xmm0
        addq    $48, %rsp
        popq    %rbx
        popq    %r14
        popq    %rbp
        retq
.LBB1_2:                                # %entry
        callq   __stack_chk_fail
.Lfunc_end1:
        .size   __ratio_D2A, .Lfunc_end1-__ratio_D2A
        .cfi_endproc

That said, I *do* see a difference in the values produced by that strtod te=
st,
e.g. libc compiled with 3.9.1 or 4.0.0 gives:

3.9.1: 10633823966279326983230456482242756608.000000
4.0.0: 10633823966279321080272352895186239488.000000

This is consistent on i386 and amd64.  Certainly needs a bit more
investigation.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-216770-13-gZvZHqLGbe>