[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Libjit] Basic float32 issue
From: |
Aleksey Demakov |
Subject: |
Re: [Libjit] Basic float32 issue |
Date: |
Sun, 17 Apr 2016 22:45:20 +0600 |
Hi Matt,
Thanks for the report. I will take a look into it in the next few days.
Regards,
Aleksey
On Sun, Apr 17, 2016 at 7:52 AM, Matthew Keeter <address@hidden> wrote:
> Digging a little deeper, the IR looks fine but the generated assembly is
> missing a data / bss section with float constants:
>
> Before compiling:
> function test() : float32
> .L:
> return_float32(19.000000)
> ends_in_dead
> .L:
> .L:
> end
>
> After compiling:
> function test() : float32
>
> /tmp/libjit-dump.o: file format mach-o-x86-64
>
>
> Disassembly of section .text:
>
> 000000010413914c <.text>:
> 10413914c: 55 push %rbp
> 10413914d: 48 8b ec mov %rsp,%rbp
> 104139150: f3 0f 10 05 78 fe 00 movss 0xfe78(%rip),%xmm0 #
> 0x104148fd0
> 104139157: 00
> 104139158: 48 8b e5 mov %rbp,%rsp
> 10413915b: 5d pop %rbp
> 10413915c: c3 retq
>
> end
>
> In particular, note that
> movss 0xfe78(%rip),%xmm0 # 0x104148fd0
> is pointing off into space.
>
> Does this ring any bells?
>
> Thanks,
> Matt
>
> On Apr 16, 2016, at 9:09 PM, Matthew Keeter <address@hidden> wrote:
>
> Hi all,
>
> I’m having trouble with floating-point operations and have reduced to a very
> simple test case.
> The code below creates a function with no arguments that just returns a
> float32 constant.
>
> For some reason, instead of returning the constant’s value, it always gives
> zero.
>
> Identical code with jit_type_int works fine, so I’m puzzled as to what’s
> going on.
> Any ideas? The code is pasted below
>
> Thanks,
> Matt
>
> {
> jit_context_t context;
> jit_type_t signature;
> jit_function_t function;
> jit_value_t c;
> jit_float32 result;
>
> context = jit_context_create();
> jit_context_build_start(context);
>
> signature = jit_type_create_signature
> (jit_abi_cdecl, jit_type_float32, NULL, 0, 1);
>
> function = jit_function_create(context, signature);
>
> c = jit_value_create_float32_constant(function, jit_type_float32,
> (jit_float32)13.0f);
> jit_insn_return(function, c);
>
> jit_function_compile(function);
> jit_context_build_end(context);
> jit_function_apply(function, NULL, &result);
> printf("const(13) = %f\n", (float)result);
>
> jit_context_destroy(context);
> }
>
>