Bug 32935 - [4.3 Regression] internal compiler error: in emit_move_insn, at expr.c:3316
Summary: [4.3 Regression] internal compiler error: in emit_move_insn, at expr.c:3316
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Andrew Pinski
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-valid-code, patch
Depends on:
Blocks: 22368
  Show dependency treegraph
 
Reported: 2007-07-30 11:33 UTC by Florian Ladstaedter
Modified: 2007-08-04 00:44 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.1 4.1.3
Known to fail: 4.3.0
Last reconfirmed: 2007-07-30 12:41:03


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Ladstaedter 2007-07-30 11:33:30 UTC
Using r127057 I get an internal compiler error with the following testcase:

-----------------------------------------------------------------
program test_gfortran2

implicit none

Integer,      Parameter :: &
   Double  =  Selected_Real_Kind(15,200)
Integer :: j

Complex(Double) :: g(5)
Complex(Double) :: zh(38)
Real(Double)    :: g_q(5)

do j=1,3
  g(:) = conjg(-(zh(j)/cmplx(0.0_Double, -g_q(:), Double)))- &
         zh(j)/cmplx(0,-g_q(:))
end do

end
-----------------------------------------------------------------


gfortran -c test_gfortran2.f90 gives:

-----------------------------------------------------------------
test_gfortran2.f90:15: internal compiler error: in emit_move_insn, at expr.c:3316
----------------------------------------------------------------- 


gfortran 4.2.1 compiles fine. Platform is i686, trying this on a Debian lenny system.
Comment 1 Dominique d'Humieres 2007-07-30 11:52:43 UTC
Confirmed on PPC Darwin8, ICE on 4.3, pass on 4.2
Comment 2 Tobias Burnus 2007-07-30 12:41:03 UTC
Works with 2007-02-02-r121508 (on x86-64-linux)
Fails with 2007-02-02-r121519 (on x86-64-linux)

Ignoring Java and testsuite changes one finds the following changelog:

gcc/ChangeLog:

+2007-02-02  Ian Lance Taylor  <iant@google.com>
+       * expmed.c (expand_divmod): Add comment.
+2007-02-02  Kazu Hirata  <kazu@codesourcery.com>
+       * emit-rtl.c (renumber_insns): Remove.
+       * flags.h: Remove the extern for flag_renumber_insns.
+       * rtl.h: Remove the prototype for renumber_insns.
+       * toplev.c (flag_renumber_insns): Remove.
+2007-02-02  Hui-May Chang  <hm.chang@apple.com>
+       Revert for x86 darwin:
+       2005-06-19  Uros Bizjak  <uros@kss-loka.si>
+       * config/i386/i386.c (ix86_function_arg_regno_p): Put back the
+       code before the following patch under TARGET_MACHO.
+       (ix86_function_value_regno_p): Likewise.
+2007-02-02  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+       * fold-const.c (negate_expr_p, fold_negate_expr): Handle
+       COMPLEX_EXPR.
+2007-02-02  Maxim Kuvyrkov  <mkuvyrkov@ispras.ru>
+       PR target/29682
+       * config/ia64/ia64.c (ia64_speculate_insn): Restrict to memory loads to
+       general or fp registers.  Add comments.
+       * config/ia64/ia64.md (reg_pred_prefix): Add comment.
Comment 3 Daniel Franke 2007-07-30 13:36:24 UTC
Reduced testcase:

program test_gfortran2
  Complex(8) :: g, zh
  Real(8)    :: g_q
  g =  zh/cmplx(0.0_8, -g_q, 8)  - zh/cmplx(0.0_8,-g_q)
end

This is, again, all about kinds. If all involved variables are of kind=4 or kind=8, it passes. Mixed kinds as above (cmplx(0.0_8,-g_q) returns a COMPLEX of kind=4) crash gfortran.
Comment 4 Andrew Pinski 2007-07-30 13:53:57 UTC
With stage1 based f95, I get a different ICE which shows the issue:
t.f90:2: error: type mismatch in complex expression
complex8

real8

real4

D.1336 = COMPLEX_EXPR <-0.0, D.1335>
t.f90:5: confused by earlier errors, bailing out
Comment 5 Andrew Pinski 2007-07-30 13:57:52 UTC
Here is an even shorter testcase:
program test_gfortran2
 Complex(8) :: g, zh
 Real(8)    :: g_q
 g =   zh - zh/cmplx(0.0_8,-g_q)
end
Comment 6 Andrew Pinski 2007-07-30 14:05:41 UTC
And here is a patch which fixes the ICE:
Index: fold-const.c
===================================================================
--- fold-const.c        (revision 127042)
+++ fold-const.c        (working copy)
@@ -1382,7 +1382,7 @@
        {
          tem = strip_float_extensions (t);
          if (tem != t && negate_expr_p (tem))
-           return negate_expr (tem);
+           return fold_convert (type, negate_expr (tem));
        }
       break;
 
Comment 7 Dominique d'Humieres 2007-07-31 07:59:43 UTC
> And here is a patch which fixes the ICE:

Confirmed and regtested on PPC Darwin.

Comment 8 Andrew Pinski 2007-08-01 00:25:44 UTC
Mine.
Comment 9 Andrew Pinski 2007-08-03 23:36:19 UTC
Subject: Bug 32935

Author: pinskia
Date: Fri Aug  3 23:36:05 2007
New Revision: 127190

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127190
Log:
2007-08-03  Andrew Pinski  <andrew_pinski@playstation.sony.com>
 
        PR middle-end/32935
        * fold-convert.c (fold_negate_expr <NOP_EXPR>): Convert back to the 
         correct type the negate expression.

2007-08-03  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR middle-end/32935
        * gfortran.fortran-torture/compile/complex_1.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.fortran-torture/compile/complex_1.f90
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog

Comment 10 Andrew Pinski 2007-08-03 23:38:19 UTC
Fixed.