public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225
@ 2004-09-07 10:58 wanderer at rsu dot ru
  2004-09-07 11:02 ` [Bug c++/17345] " wanderer at rsu dot ru
                   ` (24 more replies)
  0 siblings, 25 replies; 26+ messages in thread
From: wanderer at rsu dot ru @ 2004-09-07 10:58 UTC (permalink / raw)
  To: gcc-bugs

Current CVS mainline G++ (3.5.0 20040906) ICE with error message:

test.cpp: In member function `int Class1::calc()':
test.cpp:29: internal compiler error: in optimize_mode_switching, at lcm.c:1225
Please submit a full bug report,

at testcase:

---8X----------------
#include <map>

class Class1 {
  int calc();
  int num; 
  static Class1* get();
};

int Class1::calc() {
  int res = 0;

  typedef std::map<unsigned, unsigned> MapU2U;
  MapU2U mapU2U;

  for(MapU2U::iterator it = mapU2U.begin(); it != mapU2U.end(); ++it) {
    double f = it->second / get()->num;
    res = std::max( (int) f, res);
  }

  return res;
}
---X8----------------

Commandline: g++ test.cpp

-- 
           Summary: internal compiler error: in optimize_mode_switching, at
                    lcm.c:1225
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wanderer at rsu dot ru
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-unknown-freebsd5.1
  GCC host triplet: i386-unknown-freebsd5.1
GCC target triplet: i386-unknown-freebsd5.1


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug c++/17345] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
@ 2004-09-07 11:02 ` wanderer at rsu dot ru
  2004-09-07 11:02 ` wanderer at rsu dot ru
                   ` (23 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: wanderer at rsu dot ru @ 2004-09-07 11:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From wanderer at rsu dot ru  2004-09-07 11:02 -------
Created an attachment (id=7063)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7063&action=view)
source


-- 


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug c++/17345] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
  2004-09-07 11:02 ` [Bug c++/17345] " wanderer at rsu dot ru
@ 2004-09-07 11:02 ` wanderer at rsu dot ru
  2004-09-07 11:03 ` wanderer at rsu dot ru
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: wanderer at rsu dot ru @ 2004-09-07 11:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From wanderer at rsu dot ru  2004-09-07 11:02 -------
Created an attachment (id=7064)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7064&action=view)
.ii file


-- 


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug c++/17345] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
  2004-09-07 11:02 ` [Bug c++/17345] " wanderer at rsu dot ru
  2004-09-07 11:02 ` wanderer at rsu dot ru
@ 2004-09-07 11:03 ` wanderer at rsu dot ru
  2004-09-07 15:24 ` [Bug rtl-optimization/17345] " pinskia at gcc dot gnu dot org
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: wanderer at rsu dot ru @ 2004-09-07 11:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From wanderer at rsu dot ru  2004-09-07 11:03 -------
Created an attachment (id=7065)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7065&action=view)
.s file


-- 


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug rtl-optimization/17345] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (2 preceding siblings ...)
  2004-09-07 11:03 ` wanderer at rsu dot ru
@ 2004-09-07 15:24 ` pinskia at gcc dot gnu dot org
  2004-09-07 16:27 ` giovannibajo at libero dot it
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-07 15:24 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |rtl-optimization


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug rtl-optimization/17345] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (3 preceding siblings ...)
  2004-09-07 15:24 ` [Bug rtl-optimization/17345] " pinskia at gcc dot gnu dot org
@ 2004-09-07 16:27 ` giovannibajo at libero dot it
  2004-09-07 16:33 ` pinskia at gcc dot gnu dot org
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: giovannibajo at libero dot it @ 2004-09-07 16:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-09-07 16:27 -------
This breaks also Ada:
http://gcc.gnu.org/ml/gcc/2004-09/msg00280.html


-- 


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug rtl-optimization/17345] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (4 preceding siblings ...)
  2004-09-07 16:27 ` giovannibajo at libero dot it
@ 2004-09-07 16:33 ` pinskia at gcc dot gnu dot org
  2004-09-07 16:34 ` [Bug rtl-optimization/17345] [3.5 Regression] " pinskia at gcc dot gnu dot org
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-07 16:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-07 16:33 -------
Jan could you look into this?  This is most likely the same failure as the Ada failure.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu dot
                   |                            |org


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug rtl-optimization/17345] [3.5 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (5 preceding siblings ...)
  2004-09-07 16:33 ` pinskia at gcc dot gnu dot org
@ 2004-09-07 16:34 ` pinskia at gcc dot gnu dot org
  2004-09-08  9:39 ` martin at mpa-garching dot mpg dot de
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-07 16:34 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
            Summary|internal compiler error: in |[3.5 Regression] internal
                   |optimize_mode_switching, at |compiler error: in
                   |lcm.c:1225                  |optimize_mode_switching, at
                   |                            |lcm.c:1225
   Target Milestone|---                         |3.5.0


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug rtl-optimization/17345] [3.5 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (6 preceding siblings ...)
  2004-09-07 16:34 ` [Bug rtl-optimization/17345] [3.5 Regression] " pinskia at gcc dot gnu dot org
@ 2004-09-08  9:39 ` martin at mpa-garching dot mpg dot de
  2004-09-08 11:15 ` giovannibajo at libero dot it
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: martin at mpa-garching dot mpg dot de @ 2004-09-08  9:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From martin at mpa-garching dot mpg dot de  2004-09-08 09:38 -------
Here is a shorter testcase
(reproduced on i686-pc-linux-gnu with gcc version 3.5.0 20040908 (experimental)):

===begin===

double sqrt(double);

template <typename T> class arr
  {
  private:
    long s;
    T *d;

  public:
    arr() : s(0), d(0) {}
    ~arr() { delete[] d; }

    void alloc (long sz);
    const T &operator[] (long n) const {return d[n];}
  };

void blah ()
  {
  arr<int> index;
  index.alloc(10);
  for (int i=0; i<10; ++i)
    {
    int l = int(sqrt(index[0]));
    if (l<0) throw 2;
    }
  }

===end===


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |martin at mpa-garching dot
                   |                            |mpg dot de


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug rtl-optimization/17345] [3.5 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (7 preceding siblings ...)
  2004-09-08  9:39 ` martin at mpa-garching dot mpg dot de
@ 2004-09-08 11:15 ` giovannibajo at libero dot it
  2004-09-08 11:21 ` [Bug middle-end/17345] " giovannibajo at libero dot it
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: giovannibajo at libero dot it @ 2004-09-08 11:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-09-08 11:15 -------
Confirmed. It didn't exist with 3.5.0 20040901, so this appeared between 
September 1st and September 6.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
      Known to fail|                            |3.5.0
      Known to work|                            |3.4.0
   Last reconfirmed|0000-00-00 00:00:00         |2004-09-08 11:15:05
               date|                            |


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug middle-end/17345] [3.5 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (8 preceding siblings ...)
  2004-09-08 11:15 ` giovannibajo at libero dot it
@ 2004-09-08 11:21 ` giovannibajo at libero dot it
  2004-09-08 16:55 ` pinskia at gcc dot gnu dot org
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: giovannibajo at libero dot it @ 2004-09-08 11:21 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-09-08 11:21 -------
: Search converges between 2004-09-04-trunk (#533) and 2004-09-05-trunk (#534).


-- 


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug middle-end/17345] [3.5 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (9 preceding siblings ...)
  2004-09-08 11:21 ` [Bug middle-end/17345] " giovannibajo at libero dot it
@ 2004-09-08 16:55 ` pinskia at gcc dot gnu dot org
  2004-09-09  8:46 ` hubicka at ucw dot cz
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-08 16:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-08 16:55 -------
Here is something smaller without templates:
double sqrt(double);
struct arr
{
  ~arr();
};
int t;
void alloc (long sz);
void blah ()
{
  arr index;
  alloc(10);
  for (int i=0; i<(int)sqrt(t); ++i)
    throw 2;
}

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2004-09-08 11:15:05         |2004-09-08 16:55:31
               date|                            |


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug middle-end/17345] [3.5 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (10 preceding siblings ...)
  2004-09-08 16:55 ` pinskia at gcc dot gnu dot org
@ 2004-09-09  8:46 ` hubicka at ucw dot cz
  2004-09-09 14:16 ` [Bug target/17345] " uros at kss-loka dot si
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: hubicka at ucw dot cz @ 2004-09-09  8:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From hubicka at ucw dot cz  2004-09-09 08:45 -------
Subject: Re:  [3.5 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225

Uros,
your patch to i387 mode switching broke QT build and following testcase:

double sqrt(double);

template <typename T> class arr
  {
  private:
    long s;
    T *d;

  public:
    arr() : s(0), d(0) {}
    ~arr() { delete[] d; }

    void alloc (long sz);
    const T &operator[] (long n) const {return d[n];}
  };

void blah ()
  {
  arr<int> index;
  index.alloc(10);
  for (int i=0; i<10; ++i)
    {
    int l = int(sqrt(index[0]));
    if (l<0) throw 2;
    }
  }

The attached patch brings us back to the I387_UNINITIALIZED trick that
was supposed to care the calls.  Actually I think it might make more
sense to have more stack slots with control words - one for each control
word setting we need and multiple OPTIMIZE_MODE_SWITCHING entities as I
outlined the plan in the original mail with patch adding the old code...

I noticed you had long discussion about this stuff before getting patch
in, so I would like to hear whether you came with something
significantly better.

Honza

Index: config/i386/i386.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.h,v
retrieving revision 1.400
diff -c -3 -p -r1.400 i386.h
*** config/i386/i386.h	4 Sep 2004 07:55:07 -0000	1.400
--- config/i386/i386.h	9 Sep 2004 08:18:02 -0000
*************** extern rtx ix86_compare_op1;	/* operand 
*** 2966,2972 ****
    (GET_CODE (I) == CALL_INSN						\
     || (GET_CODE (I) == INSN && (asm_noperands (PATTERN (I)) >= 0 	\
  				|| GET_CODE (PATTERN (I)) == ASM_INPUT))\
!    ? I387_CW_ANY 							\
     : recog_memoized (I) < 0						\
     ? I387_CW_ANY 							\
     : get_attr_i387_cw (I))
--- 2966,2972 ----
    (GET_CODE (I) == CALL_INSN						\
     || (GET_CODE (I) == INSN && (asm_noperands (PATTERN (I)) >= 0 	\
  				|| GET_CODE (PATTERN (I)) == ASM_INPUT))\
!    ? I387_CW_UNINITIALIZED						\
     : recog_memoized (I) < 0						\
     ? I387_CW_ANY 							\
     : get_attr_i387_cw (I))
*************** extern rtx ix86_compare_op1;	/* operand 
*** 2981,2987 ****
     are to be inserted.  */
  
  #define EMIT_MODE_SET(ENTITY, MODE, HARD_REGS_LIVE) 			\
!   ((MODE) != I387_CW_ANY						\
     ? emit_i387_cw_initialization (assign_386_stack_local (HImode, 1),	\
  				  assign_386_stack_local (HImode, 2),   \
  				  MODE), 0				\
--- 2981,2987 ----
     are to be inserted.  */
  
  #define EMIT_MODE_SET(ENTITY, MODE, HARD_REGS_LIVE) 			\
!   ((MODE) != I387_CW_ANY && (MODE) != I387_CW_UNINITIALIZED		\
     ? emit_i387_cw_initialization (assign_386_stack_local (HImode, 1),	\
  				  assign_386_stack_local (HImode, 2),   \
  				  MODE), 0				\
Index: config/i386/i386.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.md,v
retrieving revision 1.558
diff -c -3 -p -r1.558 i386.md
*** config/i386/i386.md	8 Sep 2004 05:08:26 -0000	1.558
--- config/i386/i386.md	9 Sep 2004 08:18:03 -0000
***************
*** 431,437 ****
  
  ;; Defines rounding mode of an FP operation.
  
! (define_attr "i387_cw" "floor,ceil,trunc,mask_pm,any"
    (const_string "any"))
  
  ;; Describe a user's asm statement.
--- 431,437 ----
  
  ;; Defines rounding mode of an FP operation.
  
! (define_attr "i387_cw" "floor,ceil,trunc,mask_pm,uninitialized,any"
    (const_string "any"))
  
  ;; Describe a user's asm statement.


-- 


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug target/17345] [3.5 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (11 preceding siblings ...)
  2004-09-09  8:46 ` hubicka at ucw dot cz
@ 2004-09-09 14:16 ` uros at kss-loka dot si
  2004-09-09 15:01 ` uros at kss-loka dot si
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: uros at kss-loka dot si @ 2004-09-09 14:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From uros at kss-loka dot si  2004-09-09 14:16 -------
Jan,

thank you very much for looking into this bugreport! I admit, I didn't notice
this report, and I'm really sorry that even with a lot of testing, my patch
broke something. Your patch fixes this breakage, could you please commit it to CVS ?

Regarding my proposal, I would suggest to change mode handling from this scheme:
...
fldcw (new_mode)
fistp [or frndint]
fldcw (saved_mode)
...

fldcw (other_mode)
fistp [or frndint]
fldcw (saved_mode)
...

into something like this:

...
fldcw (new_mode)
fistp [or frndint]
...
fldcw (other_mode)
fistp [or frndint]
...
fldcw (saved_mode)
call [or __asm] 
...
fldcw (other_mode)
fistp [or frndint[
...
fldcw (saved_mode)
return

Basically, fldcw would be emitted only when rounding mode changes. Also, with
this scheme fistp and frndint patterns could have dependency on FP_mode
register, which would hopefully address mode changing in for loops. As it is now:

...
loop {
  fldcw (new_mode)
  fistp
  fldcw (saved_mode)
}
...


a better code could be generated:
...
fldcw (new_mode)
loop {
  fistp
}
...
fldcw (saved_mode)
ret

I guess mode would need to be changed to saved before call instruction or __asm
and on return from function.

Another idea is to convert
(int) floor(double) into some kind of builtin_lfloor, etc on a tree level. This
builtin could then be expanded as fix_floor?f?i optab, and this could be
implemented with sse instructions as it is a case with fix_trunc?f?i optabs.
However, SSE has its own mode register and if handled the same way as i387 mode
register, another two stack slots would be needed to save old and new SSE
rounding mode value.

It is quite interesting, how many cases would this convertions catch. For
example, povray-3.50c:

grep floor *.cpp | grep int - | wc -l
     39
grep floor *.cpp | grep long - | wc -l
      7
grep ceil *.cpp | grep int - | wc -l
      8

Uros.

-- 


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug target/17345] [3.5 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (12 preceding siblings ...)
  2004-09-09 14:16 ` [Bug target/17345] " uros at kss-loka dot si
@ 2004-09-09 15:01 ` uros at kss-loka dot si
  2004-09-09 15:14 ` hubicka at ucw dot cz
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: uros at kss-loka dot si @ 2004-09-09 15:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From uros at kss-loka dot si  2004-09-09 15:01 -------
Jan,

what is your opinion on attached patch (slots.diff) which implements your idea
of each control word having its own local stack slot?

Uros.

-- 


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug target/17345] [3.5 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (13 preceding siblings ...)
  2004-09-09 15:01 ` uros at kss-loka dot si
@ 2004-09-09 15:14 ` hubicka at ucw dot cz
  2004-09-09 15:17 ` hubicka at ucw dot cz
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: hubicka at ucw dot cz @ 2004-09-09 15:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From hubicka at ucw dot cz  2004-09-09 15:14 -------
Subject: Re:  [3.5 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225

> 
> ------- Additional Comments From uros at kss-loka dot si  2004-09-09 15:01 -------
> Jan,
> 
> what is your opinion on attached patch (slots.diff) which implements your idea
> of each control word having its own local stack slot?

Does it actually help something in this form?  I think we will still end
up reinitializing them at each change from one mode to another.  What we
really need is either somewhat extended optimize_mode_switching
interface or create independent entities for these so multiple of them
can be intialized at once...

Honza
> 
> Uros.
> 
> -- 
> 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17345
> 
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug, or are watching someone who is.


-- 


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug target/17345] [3.5 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (14 preceding siblings ...)
  2004-09-09 15:14 ` hubicka at ucw dot cz
@ 2004-09-09 15:17 ` hubicka at ucw dot cz
  2004-09-09 20:14 ` drow at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: hubicka at ucw dot cz @ 2004-09-09 15:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From hubicka at ucw dot cz  2004-09-09 15:17 -------
Subject: Re:  [3.5 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225

> 
> ------- Additional Comments From uros at kss-loka dot si  2004-09-09 14:16 -------
> Jan,
> 
> thank you very much for looking into this bugreport! I admit, I didn't notice
> this report, and I'm really sorry that even with a lot of testing, my patch

The abnormal edges happen commonly only for C++ so it is rather dificult
to catch.

> broke something. Your patch fixes this breakage, could you please commit it to CVS ?

I guess I need approval for this kind of patch...
> 
> Regarding my proposal, I would suggest to change mode handling from this scheme:
> ...
> fldcw (new_mode)
> fistp [or frndint]
> fldcw (saved_mode)
> ...
> 
> fldcw (other_mode)
> fistp [or frndint]
> fldcw (saved_mode)
> ...
> 
> into something like this:
> 
> ...
> fldcw (new_mode)
> fistp [or frndint]
> ...
> fldcw (other_mode)
> fistp [or frndint]
> ...
> fldcw (saved_mode)
> call [or __asm] 
> ...
> fldcw (other_mode)
> fistp [or frndint[
> ...
> fldcw (saved_mode)
> return

This is dificult to do.  Basically the loads of control word needs to
depend on where reload ends up putting spilling code.  There are two
schemes - we might either teach reload to do spilling always in 80bit
precision.  This will kill performance somewhat but it might be usefull
for people who need independency of results on optimization.

Other scheme is to follow the current mode switching with a pass after
reload that will insert actual loads from previously inserted
computations.
> 
> Basically, fldcw would be emitted only when rounding mode changes. Also, with
> this scheme fistp and frndint patterns could have dependency on FP_mode
> register, which would hopefully address mode changing in for loops. As it is now:
> 
> ...
> loop {
>   fldcw (new_mode)
>   fistp
>   fldcw (saved_mode)

At same time it is important to not recaluclate saved_mode and new_mode
unnecesarily.  i think with your patch we will end up redoing the
computation every time we need different rounding modes (ie try floor
and ceil together in single loop)

> }
> ...
> 
> 
> a better code could be generated:
> ...
> fldcw (new_mode)
> loop {
>   fistp
> }
> ...
> fldcw (saved_mode)
> ret
> 
> I guess mode would need to be changed to saved before call instruction or __asm
> and on return from function.
> 
> Another idea is to convert
> (int) floor(double) into some kind of builtin_lfloor, etc on a tree level. This
> builtin could then be expanded as fix_floor?f?i optab, and this could be
> implemented with sse instructions as it is a case with fix_trunc?f?i optabs.
> However, SSE has its own mode register and if handled the same way as i387 mode
> register, another two stack slots would be needed to save old and new SSE
> rounding mode value.

I already (at least partly) implemented this.
See mathfn_built_in and associated code.
In the case we are missing some cases, just add more of them.

Honza
> 
> It is quite interesting, how many cases would this convertions catch. For
> example, povray-3.50c:
> 
> grep floor *.cpp | grep int - | wc -l
>      39
> grep floor *.cpp | grep long - | wc -l
>       7
> grep ceil *.cpp | grep int - | wc -l
>       8
> 
> Uros.
> 
> -- 
> 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17345
> 
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug, or are watching someone who is.


-- 


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug target/17345] [3.5 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (15 preceding siblings ...)
  2004-09-09 15:17 ` hubicka at ucw dot cz
@ 2004-09-09 20:14 ` drow at gcc dot gnu dot org
  2004-09-10  5:38 ` [Bug target/17345] [4.0 " uros at kss-loka dot si
                   ` (7 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: drow at gcc dot gnu dot org @ 2004-09-09 20:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From drow at gcc dot gnu dot org  2004-09-09 20:14 -------
Jan asked me to check if this fixed compilation of Qt on i386-linux.  It fixes
the optimize_mode_switching crash, although Qt still doesn't build:
/home/drow/qt/qt/src/kernel/qpsprinter.cpp: In function `QByteArray
compress(const QImage&, bool)':
/home/drow/qt/qt/src/kernel/qpsprinter.cpp:5714: error: unrecognizable insn:
(insn:HI 1509 1479 1510 146 (set (reg/f:SI 84 [ T.9069 ])
        (const:SI (minus:SI (const_int -8 [0xfffffff8])
                (symbol_ref:SI ("ol_table.80550") [flags 0x2] <var_decl
0x56199e0c ol_table>)))) -1 (nil
)
    (expr_list:REG_EQUAL (const:SI (minus:SI (const_int -8 [0xfffffff8])
                (symbol_ref:SI ("ol_table.80550") [flags 0x2] <var_decl
0x56199e0c ol_table>)))
        (nil)))


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|3.5.0                       |4.0


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug target/17345] [4.0 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (16 preceding siblings ...)
  2004-09-09 20:14 ` drow at gcc dot gnu dot org
@ 2004-09-10  5:38 ` uros at kss-loka dot si
  2004-09-10  7:35 ` hubicka at ucw dot cz
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: uros at kss-loka dot si @ 2004-09-10  5:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From uros at kss-loka dot si  2004-09-10 05:38 -------
Subject:  [3.5 Regression] internal compiler error: in optimize_mode_switching,
 at lcm.c:1225

(In reply to comment #14)

 > Does it actually help something in this form?  I think we will still end
 > up reinitializing them at each change from one mode to another.  What we
 > really need is either somewhat extended optimize_mode_switching
 > interface or create independent entities for these so multiple of them
 > can be intialized at once...

Hm, it looks I misunderstood the problem. You are right, my patch does 
not move the reinitializiation of control words out of for loops. This 
testcase will show the problem:

double test() {
        double a;
        double x;

        for (x == 0; x < 10.0; x += 1.0)
                a += ceil (x) + floor (x);
        return a;
}

When compiled with '-O2 -ffast-math', CW is initialized inside for loop.

Uros.


-- 


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug target/17345] [4.0 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (17 preceding siblings ...)
  2004-09-10  5:38 ` [Bug target/17345] [4.0 " uros at kss-loka dot si
@ 2004-09-10  7:35 ` hubicka at ucw dot cz
  2004-09-10  8:23 ` hubicka at ucw dot cz
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: hubicka at ucw dot cz @ 2004-09-10  7:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From hubicka at ucw dot cz  2004-09-10 07:35 -------
Subject: Re:  [4.0 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225

Hi,
any idea how to reproduce this for me?  (using plain cross on linux
preprocessed file seems to be happy).  Would be possible to have
preprocessed testcase from cygwin?

Honza


-- 


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug target/17345] [4.0 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (18 preceding siblings ...)
  2004-09-10  7:35 ` hubicka at ucw dot cz
@ 2004-09-10  8:23 ` hubicka at ucw dot cz
  2004-09-10 16:11 ` drow at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: hubicka at ucw dot cz @ 2004-09-10  8:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From hubicka at ucw dot cz  2004-09-10 08:23 -------
Subject: Re:  [3.5 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225

> 
> ------- Additional Comments From drow at gcc dot gnu dot org  2004-09-09 20:14 -------
> Jan asked me to check if this fixed compilation of Qt on i386-linux.  It fixes
> the optimize_mode_switching crash, although Qt still doesn't build:
> /home/drow/qt/qt/src/kernel/qpsprinter.cpp: In function `QByteArray
> compress(const QImage&, bool)':
> /home/drow/qt/qt/src/kernel/qpsprinter.cpp:5714: error: unrecognizable insn:
> (insn:HI 1509 1479 1510 146 (set (reg/f:SI 84 [ T.9069 ])
>         (const:SI (minus:SI (const_int -8 [0xfffffff8])
>                 (symbol_ref:SI ("ol_table.80550") [flags 0x2] <var_decl
> 0x56199e0c ol_table>)))) -1 (nil
> )

This should be dealt with my other patch to cse.c (already applied to mainline).
If it is not, I would like to have preprocessed testcase and lets open
new PR for it as this is independent.

Thanks!
Honza
>     (expr_list:REG_EQUAL (const:SI (minus:SI (const_int -8 [0xfffffff8])
>                 (symbol_ref:SI ("ol_table.80550") [flags 0x2] <var_decl
> 0x56199e0c ol_table>)))
>         (nil)))
> 
> 
> -- 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>       Known to fail|3.5.0                       |4.0
> 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17345
> 
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug, or are watching someone who is.


-- 


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug target/17345] [4.0 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (19 preceding siblings ...)
  2004-09-10  8:23 ` hubicka at ucw dot cz
@ 2004-09-10 16:11 ` drow at gcc dot gnu dot org
  2004-09-11 20:05 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: drow at gcc dot gnu dot org @ 2004-09-10 16:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From drow at gcc dot gnu dot org  2004-09-10 16:11 -------
My mistake; looks good now.  Hopefully your fix will be committed soon.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|4.0                         |4.0.0


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug target/17345] [4.0 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (20 preceding siblings ...)
  2004-09-10 16:11 ` drow at gcc dot gnu dot org
@ 2004-09-11 20:05 ` pinskia at gcc dot gnu dot org
  2004-09-13 13:52 ` snyder at fnal dot gov
                   ` (2 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-11 20:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-11 20:05 -------
Fixed by:
        * i386.h (MODE_NEEDED): Calls need UNINITIALIZED mode; add comment.
        (EMIT_MODE_SET): UNINITIALIZED mode needs no set.
        * i386.md (i387_cw): Add 'uninitialized' mode.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug target/17345] [4.0 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (21 preceding siblings ...)
  2004-09-11 20:05 ` pinskia at gcc dot gnu dot org
@ 2004-09-13 13:52 ` snyder at fnal dot gov
  2004-09-13 14:11 ` uros at kss-loka dot si
  2004-09-13 17:34 ` giovannibajo at libero dot it
  24 siblings, 0 replies; 26+ messages in thread
From: snyder at fnal dot gov @ 2004-09-13 13:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From snyder at fnal dot gov  2004-09-13 13:52 -------
Subject: Re:  [3.5 Regression] internal compiler
 error: in optimize_mode_switching, at lcm.c:1225


Here's one without loops or throws.
I ran into this independently; it looks like a common feature is a float->int conversion.

--------------------------------------------------
struct vector
{
  ~vector();
};

float bar();
void foo(int r);

void Draw ()
{
  vector counts;
  foo ((int)bar());
}
--------------------------------------------------


-- 


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug target/17345] [4.0 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (22 preceding siblings ...)
  2004-09-13 13:52 ` snyder at fnal dot gov
@ 2004-09-13 14:11 ` uros at kss-loka dot si
  2004-09-13 17:34 ` giovannibajo at libero dot it
  24 siblings, 0 replies; 26+ messages in thread
From: uros at kss-loka dot si @ 2004-09-13 14:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From uros at kss-loka dot si  2004-09-13 14:11 -------

> Here's one without loops or throws.
> I ran into this independently; it looks like a common feature is a float->int
conversion.

This testcase passes OK with GCC: (GNU) 4.0.0 20040913 (experimental).

-- 


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug target/17345] [4.0 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
  2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
                   ` (23 preceding siblings ...)
  2004-09-13 14:11 ` uros at kss-loka dot si
@ 2004-09-13 17:34 ` giovannibajo at libero dot it
  24 siblings, 0 replies; 26+ messages in thread
From: giovannibajo at libero dot it @ 2004-09-13 17:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-09-13 17:34 -------
Honza, looks like you didn't add any testcase with your patch. Can you pleast 
add at least one of them to gcc.dg-torture?

-- 


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2004-09-13 17:34 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-07 10:58 [Bug c++/17345] New: internal compiler error: in optimize_mode_switching, at lcm.c:1225 wanderer at rsu dot ru
2004-09-07 11:02 ` [Bug c++/17345] " wanderer at rsu dot ru
2004-09-07 11:02 ` wanderer at rsu dot ru
2004-09-07 11:03 ` wanderer at rsu dot ru
2004-09-07 15:24 ` [Bug rtl-optimization/17345] " pinskia at gcc dot gnu dot org
2004-09-07 16:27 ` giovannibajo at libero dot it
2004-09-07 16:33 ` pinskia at gcc dot gnu dot org
2004-09-07 16:34 ` [Bug rtl-optimization/17345] [3.5 Regression] " pinskia at gcc dot gnu dot org
2004-09-08  9:39 ` martin at mpa-garching dot mpg dot de
2004-09-08 11:15 ` giovannibajo at libero dot it
2004-09-08 11:21 ` [Bug middle-end/17345] " giovannibajo at libero dot it
2004-09-08 16:55 ` pinskia at gcc dot gnu dot org
2004-09-09  8:46 ` hubicka at ucw dot cz
2004-09-09 14:16 ` [Bug target/17345] " uros at kss-loka dot si
2004-09-09 15:01 ` uros at kss-loka dot si
2004-09-09 15:14 ` hubicka at ucw dot cz
2004-09-09 15:17 ` hubicka at ucw dot cz
2004-09-09 20:14 ` drow at gcc dot gnu dot org
2004-09-10  5:38 ` [Bug target/17345] [4.0 " uros at kss-loka dot si
2004-09-10  7:35 ` hubicka at ucw dot cz
2004-09-10  8:23 ` hubicka at ucw dot cz
2004-09-10 16:11 ` drow at gcc dot gnu dot org
2004-09-11 20:05 ` pinskia at gcc dot gnu dot org
2004-09-13 13:52 ` snyder at fnal dot gov
2004-09-13 14:11 ` uros at kss-loka dot si
2004-09-13 17:34 ` giovannibajo at libero dot it

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).