This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] ipa-type-escape improvements


> +2007-03-01  Olga Golovanevsky  <olga@il.ibm.com>
> +
> +     * tree.h : Add multiple_of_p declaration.
> +     * fold-const.c (multiple_of_p): Make multiple_of_p public.
> +     * ipa-type-escape.c (results_of_malloc): Redundant.
> +     (visited_stmts): New. Visited stmt for walk_use_def_chains.
> +     (cast_type): Extended with new members.
> +     (check_cast): Returns cast_type.
> +     (cast): New structure for data of walk_use_def_chains.
> +     (is_malloc_result, is_cast_from_non_pointer_1,
> +     is_cast_from_non_pointer,
> +     is_array_access_through_pointer_and_index): New functions.
> +     (look_for_casts): Returns cast types.
> +     (check_call): Returns void.
> +     (okay_pointer_operation): Use support of pointer plus index,
> +     pointer plus constant and allow all multiplications.

This breaks Ada on x86 with tree checking enabled.  To reproduce, compile the 
attached reproducer in the objdir directory with:

gcc/xgcc -Bgcc -S -O2 -gnatpg a-numaux.adb -Igcc/ada/rts

+===========================GNAT BUG DETECTED==============================+
| 4.3.0 20070313 (experimental) (i586-suse-linux-gnu) GCC error:           |
| tree check: expected class 'expression', have 'constant' (real_cst)      |
|     in look_for_casts, at ipa-type-escape.c:1249                         |
| Error detected at a-numaux.adb:37:1                   

-- 
Eric Botcazou
package Ada.Numerics.Aux is

   type Double is new Long_Long_Float;

   function Exp (X : Double) return Double;

   function Tanh (X : Double) return Double;

end Ada.Numerics.Aux;
with System.Machine_Code; use System.Machine_Code;

package body Ada.Numerics.Aux is

   NL : constant String := ASCII.LF & ASCII.HT;

   function Exp (X : Double) return Double is
      Result : Double;
   begin
      Asm (Template =>
         "fldl2e               " & NL
       & "fmulp   %%st, %%st(1)" & NL -- X * log2 (E)
       & "fld     %%st(0)      " & NL
       & "frndint              " & NL -- Integer (X * Log2 (E))
       & "fsubr   %%st, %%st(1)" & NL -- Fraction (X * Log2 (E))
       & "fxch                 " & NL
       & "f2xm1                " & NL -- 2**(...) - 1
       & "fld1                 " & NL
       & "faddp   %%st, %%st(1)" & NL -- 2**(Fraction (X * Log2 (E)))
       & "fscale               " & NL -- E ** X
       & "fstp    %%st(1)      ",
         Outputs  => Double'Asm_Output ("=t", Result),
         Inputs   => Double'Asm_Input  ("0", X));
      return Result;
   end Exp;

   function Tanh (X : Double) return Double is
   begin

      if abs X > 23.0 then
         return Double'Copy_Sign (1.0, X);
      end if;

      return 1.0 / (1.0 + Exp (-(2.0 * X))) - 1.0 / (1.0 + Exp (2.0 * X));
   end Tanh;

end Ada.Numerics.Aux;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]