This is the mail archive of the gcc@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]

Success report on Linux/PPC, small Ada problem


I have taken the current gcc 3.1 CVS sources and bootstrapped it 
(including Ada) on Linux/PPC.  Everything went smoothly, I added the 
machine-specific stuff for Linux/PPC for Ada.

I built the Linux kernel, and at first it didn't work, but I had 
accidentally recompiled part of the code with the 2.95.3 compiler.  That 
seems odd, but once I recompiled with gcc 3.1 completely, it worked fine.

I ran a test suite I had for Ada, and I only ran into one small problem. 
 I've traced it down to the Is_Negative Ada intrinsic not working 
reliably when compiled with -O2.  It doesn't reliably work for zero, it 
sometimes detects 0.0 is -0.0, and sometimes vice versa (probably 
depends on the code around it).  This is just for PPC, for x86 it works 
fine.  I haven't done much more to track this down, and I don't know 
much about IEEE floating point, but the actual code for negative 
detection seems odd.  Why not just check the sign bit?

The following code:

package System.Tester3_X is -- name file s-testex.ads

   function Is_Negative (V : Long_Long_Float) return Boolean;
   pragma Import (Intrinsic, Is_Negative);

end System.Tester3_X;

with Ada.Text_IO;
use Ada.Text_IO;
with System.Tester3_X; use System.Tester3_X;

procedure Tester3 is
   val2 : Float := 0.0;
   Val : String := Float'Image(Val2);
   procedure X1(X : Float) is
   begin
      if (X < 0.0) then
         Put_Line("Is Negative 1");
      end if;
      if (Is_Negative(Long_Long_Float(X))) then
         Put_Line("Is Negative 2");
      end if;
   end X1;
begin
   Put_Line("Val: '" & Val & "'");
   Put_Line("Val: '" & Float'Image(0.0) & "'");
   Put_Line("Constant");
   X1(0.0);
   Put_Line("Variable");
   X1(Val2);
end Tester3;

Should produce the following output:

Val: ' 0.00000E+00'
Val: ' 0.00000E+00'
Constant
Variable

On the PPC, it produces the following output:

Val: '0.00000E+00'   <= Notice there is no space here at the beginning
Val: '-0.00000E+00'
Constant
Is Negative 2 <= The value should not be negative.
Variable
Is Negative 2 <= The value should not be negative.

If you move things around and change things, the behaviour changes.

-Corey


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