[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-01 Thread mueller at kde dot org


--- Comment #1 from mueller at kde dot org  2005-11-01 23:06 ---
Created an attachment (id=10110)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10110&action=view)
testcase

-O1 or higher exposes the bug. 

-fno-tree-dce or undoing commit 101841 fixes it. 


-- 


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



[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-01 Thread steven at gcc dot gnu dot org


--- Comment #2 from steven at gcc dot gnu dot org  2005-11-01 23:08 ---
-fno-tree-loop-im fixes it too, fwiw.


-- 

steven at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
 Ever Confirmed|0   |1
   Last reconfirmed|-00-00 00:00:00 |2005-11-01 23:08:47
   date||


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



[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-01 Thread steven at gcc dot gnu dot org


--- Comment #3 from steven at gcc dot gnu dot org  2005-11-01 23:09 ---
Most likely aliasing related.


-- 

steven at gcc dot gnu dot org changed:

   What|Removed |Added

   Keywords||alias


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



[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-01 Thread steven at gcc dot gnu dot org


--- Comment #4 from steven at gcc dot gnu dot org  2005-11-01 23:09 ---
Mark, this is a new wrong-code bug.
Could you look at it and set a priority please.


-- 

steven at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||mark at codesourcery dot com
   Keywords||wrong-code


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



[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-01 Thread pinskia at gcc dot gnu dot org


-- 

pinskia at gcc dot gnu dot org changed:

   What|Removed |Added

   GCC host triplet|i686-gnu-linux  |
 GCC target triplet||i686-gnu-linux
   Target Milestone|--- |4.1.0


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



[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-01 Thread pinskia at gcc dot gnu dot org


--- Comment #5 from pinskia at gcc dot gnu dot org  2005-11-01 23:12 ---
Note this is union related as if I remove the unions, it works.


-- 


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



[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-01 Thread pinskia at gcc dot gnu dot org


--- Comment #6 from pinskia at gcc dot gnu dot org  2005-11-01 23:22 ---
Here is a little cleaned up testcase without any do {} while(0);:
extern void abort (void) __attribute__ ((noreturn));

typedef unsigned int u_int32;
typedef struct {
  union {u_int32 Xl_ui;} Ul_i;
  union {u_int32 Xl_uf;} Ul_f;
} l_fp;
void dolfptoa(short ndec)
{
  l_fp work, ftmp;
  work.Ul_i.Xl_ui = 0;
  work.Ul_f.Xl_uf = 0x535f3d8;
  while (ndec > 0) {

ndec--;
work.Ul_i.Xl_ui = 0;
work.Ul_i.Xl_ui <<= 1;
if ((work.Ul_f.Xl_uf) & 0x8000)
  (work.Ul_i.Xl_ui) |= 0x1; (work.Ul_f.Xl_uf) <<= 1;
  //  printf("%d\t", work.Ul_i.Xl_ui);

ftmp = work;
(work.Ul_i.Xl_ui) <<= 1;
if ((work.Ul_f.Xl_uf) & 0x8000)
  (work.Ul_i.Xl_ui) |= 0x1; (work.Ul_f.Xl_uf) <<= 1;

(work.Ul_i.Xl_ui) <<= 1;
if ((work.Ul_f.Xl_uf) & 0x8000)
  (work.Ul_i.Xl_ui) |= 0x1; (work.Ul_f.Xl_uf) <<= 1;
  //  printf("%d\t", work.Ul_i.Xl_ui);
u_int32 lo_tmp;
u_int32 hi_tmp;
lo_tmp = ((work.Ul_f.Xl_uf) & 0x) + ((ftmp.Ul_f.Xl_uf) & 0x);
hi_tmp = (((work.Ul_f.Xl_uf) >> 16) & 0x) + (((ftmp.Ul_f.Xl_uf) >> 16)
& 0x);

if (lo_tmp & 0x1)
  hi_tmp++;

(work.Ul_f.Xl_uf) = ((hi_tmp & 0x) << 16) | (lo_tmp & 0x);
(work.Ul_i.Xl_ui) += (ftmp.Ul_i.Xl_ui);

if (hi_tmp & 0x1)
 (work.Ul_i.Xl_ui)++;
   // printf("%d\n", work.Ul_i.Xl_ui);
if (!(work.Ul_i.Xl_ui < 10))
  abort ();
  }
}
int main()
{
  dolfptoa(6);
  return 0;
}


-- 


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



[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-01 Thread pinskia at gcc dot gnu dot org


--- Comment #7 from pinskia at gcc dot gnu dot org  2005-11-01 23:32 ---
wtf:
-  #   SFT.1_22 = V_MUST_DEF ;
+  #   SFT.1_22 = V_MUST_DEF ;
   work.Ul_i.Xl_ui = D.1298_21;
...
-  # SFT.1_10 = PHI ;

That is just wrong.  DCE is doing something wrong, very wrong.


-- 


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



[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-01 Thread pinskia at gcc dot gnu dot org


--- Comment #8 from pinskia at gcc dot gnu dot org  2005-11-01 23:34 ---
Eliminating unnecessary statements:
Deleting : SFT.1_10 = PHI ;

Deleting : work.Ul_i.Xl_ui = 0;

Deleting : work.Ul_i.Xl_ui = 0;

Deleting : work.Ul_f.Xl_uf = D.1302_36;

Deleting : work.Ul_f.Xl_uf = D.1302_44;


No SFT.1_10 = PHI ; is not useless


-- 


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



[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-01 Thread mmitchel at gcc dot gnu dot org


--- Comment #9 from mmitchel at gcc dot gnu dot org  2005-11-02 00:55 
---
Miscompilation of a popular package on a major architecture; showstopper.


-- 

mmitchel at gcc dot gnu dot org changed:

   What|Removed |Added

   Priority|P3  |P1


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



[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-01 Thread dnovillo at gcc dot gnu dot org


-- 

dnovillo at gcc dot gnu dot org changed:

   What|Removed |Added

 CC|dnovillo at redhat dot com  |
 AssignedTo|unassigned at gcc dot gnu   |dnovillo at gcc dot gnu dot
   |dot org |org
 Status|NEW |ASSIGNED


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



[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-02 Thread pinskia at gcc dot gnu dot org


--- Comment #10 from pinskia at gcc dot gnu dot org  2005-11-02 15:47 
---
Here is a further reduced testase:
typedef struct {
  union {unsigned Xl_ui;} Ul_i;
  union {unsigned Xl_uf;} Ul_f;
} l_fp;
void dolfptoa(short ndec)
{
  l_fp work;
  work.Ul_f.Xl_uf = 0x535f3d8;
  while (ndec > 0) {

ndec--;
work.Ul_i.Xl_ui = 0;
work.Ul_i.Xl_ui = 0;
if ((work.Ul_f.Xl_uf) & 0x8000)
  (work.Ul_i.Xl_ui) |= 0x1;
(work.Ul_f.Xl_uf) <<= 1;

(work.Ul_i.Xl_ui) <<= 1;
if ((work.Ul_f.Xl_uf) & 0x8000)
  (work.Ul_i.Xl_ui) |= 0x1;
(work.Ul_f.Xl_uf) <<= 1;

(work.Ul_i.Xl_ui) <<= 1;

if (!(work.Ul_i.Xl_ui < 10))
  abort ();
  }
}
int main()
{
  dolfptoa(6);
  return 0;
}


-- 


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



[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-02 Thread pinskia at gcc dot gnu dot org


--- Comment #11 from pinskia at gcc dot gnu dot org  2005-11-02 15:53 
---
The following fails with -O1 -fno-tree-sra.
typedef struct {
  struct {unsigned Xl_ui;} Ul_i;
  struct {unsigned Xl_uf;} Ul_f;
} l_fp;
void dolfptoa(short ndec)
{
  l_fp work;
  work.Ul_f.Xl_uf = 0x535f3d8;
  while (ndec > 0) {

ndec--;
work.Ul_i.Xl_ui = 0;
work.Ul_i.Xl_ui = 0;
if ((work.Ul_f.Xl_uf) & 0x8000)
  (work.Ul_i.Xl_ui) |= 0x1;
(work.Ul_f.Xl_uf) <<= 1;

(work.Ul_i.Xl_ui) <<= 1;
if ((work.Ul_f.Xl_uf) & 0x8000)
  (work.Ul_i.Xl_ui) |= 0x1;
(work.Ul_f.Xl_uf) <<= 1;

(work.Ul_i.Xl_ui) <<= 1;

if (!(work.Ul_i.Xl_ui < 10))
  abort ();
  }
}
int main()
{
  dolfptoa(6);
  return 0;
}


The -fno-tree-sra is need as otherwise SRA actually does it work and renames
the PHIs correctly.


-- 


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



[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-02 Thread pinskia at gcc dot gnu dot org


--- Comment #12 from pinskia at gcc dot gnu dot org  2005-11-02 16:03 
---
Here is another more reduced testcase (still at -O1 -fno-tree-sra):
typedef struct {
  unsigned a;
} l_fp;
void dolfptoa(short ndec)
{
  l_fp work;
  unsigned workUl_fXl_uf;
  work.a = 0x535f3d8;
  while (ndec > 0) {

ndec--;
work.a = 0;
work.a = 0;
if (workUl_fXl_uf & 0x8000)
  work.a |= 0x1;
workUl_fXl_uf <<= 1;

work.a <<= 1;
if (workUl_fXl_uf & 0x8000)
  work.a |= 0x1;
workUl_fXl_uf <<= 1;

work.a <<= 1;

if (!(work.a < 10))
  abort ();
  }
}
int main()
{
  dolfptoa(6);
  return 0;
}


-- 


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



[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-02 Thread pinskia at gcc dot gnu dot org


--- Comment #13 from pinskia at gcc dot gnu dot org  2005-11-02 16:12 
---
(In reply to comment #12)
> Here is another more reduced testcase (still at -O1 -fno-tree-sra):
That testcase is invalid, the one which is valid:
ypedef struct {
  unsigned a;
} l_fp;
void dolfptoa(short ndec)
{
  l_fp work;
  unsigned workUl_fXl_uf;
  workUl_fXl_uf = 0x535f3d8;
  while (ndec > 0) {

ndec--;
work.a = 0;
work.a = 0;
if (workUl_fXl_uf & 0x8000)
  work.a |= 0x1;
workUl_fXl_uf <<= 1;

work.a <<= 1;
if (workUl_fXl_uf & 0x8000)
  work.a |= 0x1;
workUl_fXl_uf <<= 1;

work.a <<= 1;

if (!(work.a < 10))
  abort ();
  }
}
int main()
{
  dolfptoa(8);
  return 0;
}


-- 


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



[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-02 Thread pinskia at gcc dot gnu dot org


--- Comment #14 from pinskia at gcc dot gnu dot org  2005-11-02 16:39 
---
This is as far as I can reduce it, -O1:
typedef union {
  unsigned a;
} l_fp;
int main(void)
{
  l_fp work;
  unsigned workUl_fXl_uf = 0x;
  int ndec = 10;
  do {
ndec--;
work.a = 0;
work.a = 0;

if (workUl_fXl_uf & 1)
  work.a ++;

workUl_fXl_uf <<= 1;

work.a ++;
if (workUl_fXl_uf & 1)
  work.a ++;

work.a ++;

if (work.a > 4)
  abort ();
  }while(ndec > 0);
  return 0;
}


-- 


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



[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-02 Thread pinskia at gcc dot gnu dot org


--- Comment #15 from pinskia at gcc dot gnu dot org  2005-11-02 17:02 
---
A link to the changes (so I can be a little lazy):
http://gcc.gnu.org/viewcvs?view=rev&rev=101841


-- 


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



[Bug middle-end/24627] [4.1 Regression] xntp miscompiled

2005-11-02 Thread dnovillo at gcc dot gnu dot org


--- Comment #16 from dnovillo at gcc dot gnu dot org  2005-11-02 19:40 
---

testing patch


-- 


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