Bug 12828 - -floop-optimize is unstable on PowerPC (float to int conversion problem)
Summary: -floop-optimize is unstable on PowerPC (float to int conversion problem)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.3.2
: P2 normal
Target Milestone: 3.4.0
Assignee: Dale Johannesen
URL:
Keywords: patch, wrong-code
: 14947 17072 20327 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-10-29 17:40 UTC by Carl Henrik Holth Lunde
Modified: 2005-03-05 01:27 UTC (History)
5 users (show)

See Also:
Host:
Target: powerpc-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-10-30 05:12:33


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carl Henrik Holth Lunde 2003-10-29 17:40:46 UTC
Perfectly fine code seems to give segmentation faults on PowerPC with the new 
-floop-optimize flag.  I've only tested this with GCC 3.3.2 from Debian 
unstable. 
 
Here's a small example of code which gives SIGSEGV 
http://www.rashbox.org/~chlunde/gccloopbug.cc
Comment 1 Andrew Pinski 2003-10-29 18:01:25 UTC
Looks like some how this insn is being splitted up:
(insn 164 117 166 0x0 (parallel [
            (set (reg:DF 127)
                (unsigned_float:DF (reg/v:SI 122)))
            (use (reg:SI 128))
            (use (reg:DF 129))
            (clobber (mem:DF (plus:SI (reg/f:SI 30 r30)
                        (reg:SI 141)) [0 S8 A8]))
            (clobber (reg:DF 130))
        ]) -1 (nil)
    (expr_list:REG_EQUAL (unsigned_float:DF (reg/v:SI 122))
        (nil)))
Comment 2 Andrew Pinski 2003-10-30 05:08:50 UTC
Here is the code:
/*
 * This gives me a SIGSEGV when compiled with -floop-optimize on PPC w/3.3
 * chlunde at ifi.uio.no
 */
#include <math.h>

typedef unsigned int uint;

int main(int, char**)
{
  const uint size = 181; // 180 and lower seems to work
  unsigned char data[size][size];

  for(uint x = 0; x < size; ++x)
  {
    for(uint y = 0; y < size; ++y)
    {
      int intensity = (int)(x * 10.0); // This is needed
      data[y][x] = (intensity >= 0) ? 0 : 1;
    }
  }
}

// vim: ts=2 sw=2 et
Comment 3 Andrew Pinski 2003-10-30 05:12:31 UTC
The include to math.h is not needed.
I can reproduce it on the mainline (20031029).
Comment 4 Debian GCC Maintainers 2003-11-02 20:46:02 UTC
[ reported to http://bugs.debian.org/218219 as well ]
Comment 5 Andrew Pinski 2003-12-08 20:25:32 UTC
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2003-12/msg00785.html>.
Comment 6 Andrew Pinski 2003-12-19 07:13:57 UTC
Dale the patch was okayed, could you apply it?
Comment 7 GCC Commits 2003-12-22 18:23:18 UTC
Subject: Bug 12828

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	dalej@gcc.gnu.org	2003-12-22 18:23:15

Modified files:
	gcc            : ChangeLog regclass.c loop.c 

Log message:
	2003-12-21  Dale Johannesen  <dalej@apple.com>
	
	PR optimization/12828
	* loop.c:  Add find_regs_nested to look inside CLOBBER(MEM).
	(scan_loop):  Call it.
	* regclass.c (reg_scan_mark_regs):  Look inside CLOBBER(MEM).

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.2072&r2=2.2073
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/regclass.c.diff?cvsroot=gcc&r1=1.182&r2=1.183
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/loop.c.diff?cvsroot=gcc&r1=1.482&r2=1.483

Comment 8 Dale Johannesen 2003-12-22 18:32:11 UTC
Fixed by patch shown in #7.
Comment 9 Andrew Pinski 2004-04-13 22:00:14 UTC
*** Bug 14947 has been marked as a duplicate of this bug. ***
Comment 10 Andrew Pinski 2004-08-18 02:29:12 UTC
*** Bug 17072 has been marked as a duplicate of this bug. ***
Comment 11 Andrew Pinski 2005-03-05 01:27:31 UTC
*** Bug 20327 has been marked as a duplicate of this bug. ***