------- Comment #3 from uros at kss-loka dot si  2006-04-12 17:54 -------
> There seems to be something wrong with -ffast-math and floor.

I have done some analysis on this. Start from expand_builtin_int_roundingfn()
in builtins.c source, where we fallback to FP rounding optab.

fallback_fndecl from mathfn_builtin looks like:

 <function_decl 0x2aaaad992200 __builtin_floor
    type <function_type 0x2aaaad9756e0
        type <real_type 0x2aaaad970420 double DF
            size <integer_cst 0x2aaaad951d80 constant invariant 64>
            unit size <integer_cst 0x2aaaad951db0 constant invariant 8>
            align 64 symtab 0 alias set -1 precision 64
            pointer_to_this <pointer_type 0x2aaaad970630>>
        QI
        size <integer_cst 0x2aaaad9517e0 constant invariant 8>
        unit size <integer_cst 0x2aaaad951810 constant invariant 1>
        align 8 symtab 0 alias set -1
        arg-types <tree_list 0x2aaaad9740f0 value <real_type 0x2aaaad970420
double>
            chain <tree_list 0x2aaaad96be10 value <void_type 0x2aaaad9700b0
void>>>
        pointer_to_this <pointer_type 0x2aaaadabad10>>
    readonly used nothrow public external built-in decl_6 QI file <built-in>
line 0
    built-in BUILT_IN_NORMAL:BUILT_IN_FLOOR attributes <tree_list
0x2aaaad9918d0>
    (mem:QI (symbol_ref:DI ("floor") [flags 0x41] <function_decl 0x2aaaad992200
__builtin_floor>) [0 S1 A8]) chain <function_decl 0x2aaaad992300 floor>>



After that, build_function_call_expr() is called, with an argument list:

 <tree_list 0x2aaaadabf180
    value <float_expr 0x2aaaad95b240
        type <real_type 0x2aaaad970420 double DF
            size <integer_cst 0x2aaaad951d80 constant invariant 64>
            unit size <integer_cst 0x2aaaad951db0 constant invariant 8>
            align 64 symtab 0 alias set -1 precision 64
            pointer_to_this <pointer_type 0x2aaaad970630>>

        arg 0 <parm_decl 0x2aaaad958780 i type <integer_type 0x2aaaad9604d0
int>
            used SI file pr27134.c line 5
            size <integer_cst 0x2aaaad951bd0 constant invariant 32>
            unit size <integer_cst 0x2aaaad9516f0 constant invariant 4>
            align 32 context <function_decl 0x2aaaadaa1600 foo> initial
<integer_type 0x2aaaad9604d0 int>
            (reg/v:SI 59 [ i ]) arg-type <integer_type 0x2aaaad9604d0 int>

This is simplified in fold_build3() to:

 <nop_expr 0x2aaaadac5300
    type <real_type 0x2aaaad970420 double DF
        size <integer_cst 0x2aaaad951d80 constant invariant 64>
        unit size <integer_cst 0x2aaaad951db0 constant invariant 8>
        align 64 symtab 0 alias set -1 precision 64
        pointer_to_this <pointer_type 0x2aaaad970630>>

    arg 0 <float_expr 0x2aaaad95b240 type <real_type 0x2aaaad970420 double>

        arg 0 <parm_decl 0x2aaaad958780 i type <integer_type 0x2aaaad9604d0
int>
            used SI file pr27134.c line 5
            size <integer_cst 0x2aaaad951bd0 constant invariant 32>
            unit size <integer_cst 0x2aaaad9516f0 constant invariant 4>
            align 32 context <function_decl 0x2aaaadaa1600 foo> initial
<integer_type 0x2aaaad9604d0 int>
            (reg/v:SI 59 [ i ]) arg-type <integer_type 0x2aaaad9604d0 int>
            incoming-rtl (reg:SI 5 di [ i ])>>>

It looks to me, that fold_convert3() is trying to kill
(int) __builtin_lfloor ((double) i), where i is an integer argument.

Uros.


-- 

uros at kss-loka dot si changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |uros at kss-loka dot si
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2006-04-12 14:59:12         |2006-04-12 17:54:41
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27134

Reply via email to