public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/49472] New: [gfortran, 4.7 regression] Compiler segfault on valid code
@ 2011-06-20 11:05 martin@mpa-garching.mpg.de
  2011-06-20 11:31 ` [Bug fortran/49472] " dominiq at lps dot ens.fr
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: martin@mpa-garching.mpg.de @ 2011-06-20 11:05 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: [gfortran, 4.7 regression] Compiler segfault on valid
                    code
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: martin@mpa-garching.mpg.de


When trying to compile the code below with gfortran 4.7 and a specific set of
flags, the compiler segfaults:

/scratch/martin/tmp/planck/lsclean>gfortran -v -g -O -ffast-math -c
CAMB/modules.f90
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/afs/mpa/data/martin/ugcc/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /scratch/martin/gcc/configure --disable-bootstrap
--disable-graphite --enable-gold --enable-plugins
--prefix=/afs/mpa/data/martin/ugcc --with-libelf=/afs/mpa/data/martin/numlibs64
--enable-languages=c++,fortran --enable-target=all --enable-checking=release
Thread model: posix
gcc version 4.7.0 20110620 (experimental) [trunk revision 175202] (GCC) 
COLLECT_GCC_OPTIONS='-v' '-g' '-O' '-ffast-math' '-c' '-mtune=generic'
'-march=x86-64'
 /afs/mpa/data/martin/ugcc/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/f951
CAMB/modules.f90 -quiet -dumpbase modules.f90 -mtune=generic -march=x86-64
-auxbase modules -g -O -version -ffast-math -fintrinsic-modules-path
/afs/mpa/data/martin/ugcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/finclude -o
/tmp/ccHb3jKV.s
GNU Fortran (GCC) version 4.7.0 20110620 (experimental) [trunk revision 175202]
(x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.5.2, GMP version 4.3.2, MPFR version 2.4.2,
MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran (GCC) version 4.7.0 20110620 (experimental) [trunk revision 175202]
(x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.5.2, GMP version 4.3.2, MPFR version 2.4.2,
MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
gfortran: internal compiler error: Segmentation fault (program f951)
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

The code compiles without complaint with gfortran 4.5.2 and the head of the 4.6
branch.


    module MassiveNu
      implicit none
        private

      integer, parameter :: dl = KIND(1.d0)
          real(dl), dimension(:), allocatable ::  r1,p1,dr1,dp1,ddr1,qdn

          real(dl), parameter :: dq=1._dl
          integer, parameter :: nqmax0=15 !number of q to sample for each l

          integer nqmax

       contains

        subroutine Nu_derivs(am,adotoa,rhonu,rhonudot,shearnudot,psi2,psi2dot)
        real(dl) psi2(nqmax0),psi2dot(nqmax0)

        real(dl) g1(nqmax0+1)
        real(dl) adotoa,rhonu,rhonudot,shearnudot
        real(dl) aq,q,v,d,aqdot,vdot,g0
        real(dl), intent(IN) :: am
        integer iq

        do iq=2,(nqmax0+1)
            q=(iq-1.5d0)*dq
            aq=am/q
            aqdot=aq*adotoa
            v=1._dl/sqrt(1._dl+aq*aq)
            vdot=-aq*aqdot/(1._dl+aq*aq)**1.5d0
            g1(iq)=qdn(iq-1)*(psi2dot(iq-1)*v+psi2(iq-1)*vdot)
        end do
        call splint(g1,g0,nqmax0+1)

        end subroutine Nu_derivs

      end module MassiveNu


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

* [Bug fortran/49472] [gfortran, 4.7 regression] Compiler segfault on valid code
  2011-06-20 11:05 [Bug fortran/49472] New: [gfortran, 4.7 regression] Compiler segfault on valid code martin@mpa-garching.mpg.de
@ 2011-06-20 11:31 ` dominiq at lps dot ens.fr
  2011-06-20 11:55 ` [Bug rtl-optimization/49472] [4.7 " rguenth at gcc dot gnu.org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: dominiq at lps dot ens.fr @ 2011-06-20 11:31 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.06.20 11:31:25
     Ever Confirmed|0                           |1

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2011-06-20 11:31:25 UTC ---
Revision 174379 is OK, 174487 is not. GDB shows

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00007fff5bc00ef8
0x000000010075c6f6 in simplify_binary_operation (code=MULT, mode=DFmode,
op0=0x141f29e10, op1=0x141f29438) at ../../work/gcc/simplify-rtx.c:1842
1842          && swap_commutative_operands_p (op0, op1))


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

* [Bug rtl-optimization/49472] [4.7 regression] Compiler segfault on valid code
  2011-06-20 11:05 [Bug fortran/49472] New: [gfortran, 4.7 regression] Compiler segfault on valid code martin@mpa-garching.mpg.de
  2011-06-20 11:31 ` [Bug fortran/49472] " dominiq at lps dot ens.fr
@ 2011-06-20 11:55 ` rguenth at gcc dot gnu.org
  2011-06-20 12:13 ` janus at gcc dot gnu.org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-06-20 11:55 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|fortran                     |rtl-optimization
   Target Milestone|---                         |4.7.0
            Summary|[gfortran, 4.7 regression]  |[4.7 regression] Compiler
                   |Compiler segfault on valid  |segfault on valid code
                   |code                        |

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-06-20 11:54:44 UTC ---
We endlessly recurse simplifying from fwprop

#20152 0x0000000001169de1 in propagate_rtx_1 (px=0x7fffffffd940, 
    old_rtx=0x7ffff5b3f7a0, new_rtx=0x7ffff5b48ba0, flags=6)
    at /space/rguenther/src/svn/trunk/gcc/fwprop.c:507
507           tem = simplify_gen_binary (code, mode, op0, op1);
(gdb) down
#20151 0x0000000000b0f51e in simplify_gen_binary (code=MULT, mode=DFmode, 
    op0=0x7ffff5b48bd0, op1=0x7ffff5b48ba0)
    at /space/rguenther/src/svn/trunk/gcc/simplify-rtx.c:117
117       tem = simplify_binary_operation (code, mode, op0, op1);
(gdb) call debug_rtx (op0)
(mult:DF (mult:DF (div:DF (reg:DF 80 [ D.1612 ])
            (reg:DF 123))
        (neg:DF (div:DF (const_double:DF 1.0e+0 [0x0.8p+1])
                (reg:DF 103 [ powroot.4 ]))))
    (reg:DF 82 [ D.1613 ]))
(gdb) call debug_rtx (op1)
(div:DF (reg:DF 80 [ D.1612 ])
    (reg:DF 123))


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

* [Bug rtl-optimization/49472] [4.7 regression] Compiler segfault on valid code
  2011-06-20 11:05 [Bug fortran/49472] New: [gfortran, 4.7 regression] Compiler segfault on valid code martin@mpa-garching.mpg.de
  2011-06-20 11:31 ` [Bug fortran/49472] " dominiq at lps dot ens.fr
  2011-06-20 11:55 ` [Bug rtl-optimization/49472] [4.7 " rguenth at gcc dot gnu.org
@ 2011-06-20 12:13 ` janus at gcc dot gnu.org
  2011-06-20 14:13 ` dominiq at lps dot ens.fr
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: janus at gcc dot gnu.org @ 2011-06-20 12:13 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |janus at gcc dot gnu.org

--- Comment #3 from janus at gcc dot gnu.org 2011-06-20 12:12:31 UTC ---
Slightly reduced test case:


module MassiveNu
  implicit none

contains

  subroutine Nu_derivs
    integer, parameter :: dl = KIND(1.d0)
    integer, parameter :: nqmax0 = 3

    real(dl) :: adotoa,aq,aqdot,vdot, g1(nqmax0+1)
    integer :: iq

    do iq=2,(nqmax0+1)
    aq=1./((iq-1.5d0)*1.)
    aqdot=aq*adotoa
    vdot=-aq*aqdot/(1.+aq*aq)**1.5d0
    g1(iq)=vdot
    end do

    call dummy(g1)

  end subroutine

end module 



This fails with

Program received signal SIGSEGV, Segmentation fault.
0x0000000000b27430 in simplify_const_unary_operation (code=Cannot access memory
at address 0x7fffff7fefec) at /home/jweil/gcc47/trunk/gcc/simplify-rtx.c:1212


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

* [Bug rtl-optimization/49472] [4.7 regression] Compiler segfault on valid code
  2011-06-20 11:05 [Bug fortran/49472] New: [gfortran, 4.7 regression] Compiler segfault on valid code martin@mpa-garching.mpg.de
                   ` (2 preceding siblings ...)
  2011-06-20 12:13 ` janus at gcc dot gnu.org
@ 2011-06-20 14:13 ` dominiq at lps dot ens.fr
  2011-06-20 14:18 ` dominiq at lps dot ens.fr
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: dominiq at lps dot ens.fr @ 2011-06-20 14:13 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wschmidt at gcc dot gnu.org

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2011-06-20 14:12:26 UTC ---
This pr has been introduced by revision 174446

Author:    wschmidt
Date:    Mon May 30 17:12:53 2011 UTC (2 weeks, 6 days ago)
Changed paths:    2
Log Message:    
2011-05-30  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

    PR tree-optimization/46728
    * tree-ssa-math-opts.c (build_and_insert_call): Reorder parms.
    (build_and_insert_binop): New.
    (gimple_expand_builtin_pow): Reorder args for
    build_and_insert_call; use build_and_insert_binop; add more
    optimizations for fractional exponents.

The minimal set of options is '-O1 -ffast-math -g'.


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

* [Bug rtl-optimization/49472] [4.7 regression] Compiler segfault on valid code
  2011-06-20 11:05 [Bug fortran/49472] New: [gfortran, 4.7 regression] Compiler segfault on valid code martin@mpa-garching.mpg.de
                   ` (3 preceding siblings ...)
  2011-06-20 14:13 ` dominiq at lps dot ens.fr
@ 2011-06-20 14:18 ` dominiq at lps dot ens.fr
  2011-06-20 15:18 ` wschmidt at gcc dot gnu.org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: dominiq at lps dot ens.fr @ 2011-06-20 14:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2011-06-20 14:17:51 UTC ---
The test in comment #3 compiles if I replace (1._dl+aq*aq)**1.5d0 with
sqrt((1._dl+aq*aq)**3).


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

* [Bug rtl-optimization/49472] [4.7 regression] Compiler segfault on valid code
  2011-06-20 11:05 [Bug fortran/49472] New: [gfortran, 4.7 regression] Compiler segfault on valid code martin@mpa-garching.mpg.de
                   ` (4 preceding siblings ...)
  2011-06-20 14:18 ` dominiq at lps dot ens.fr
@ 2011-06-20 15:18 ` wschmidt at gcc dot gnu.org
  2011-06-20 15:19 ` wschmidt at gcc dot gnu.org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2011-06-20 15:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2011-06-20 15:16:59 UTC ---
Gimple out of the middle end looks fine.  From 142t.optimized:

;; Function nu_derivs (__massivenu_MOD_nu_derivs, funcdef_no=0, decl_uid=708,
cgraph_uid=0)

nu_derivs ()
{
  real(kind=8) D.719;
  real(kind=8) vdot;
  integer(kind=4) iq;
  real(kind=8) g1[4];
  real(kind=8) aqdot;
  real(kind=8) aq;
  real(kind=8) adotoa;
  integer(kind=8) D.736;
  integer(kind=8) D.735;
  real(kind=8) D.734;
  real(kind=8) D.733;
  real(kind=8) D.732;
  real(kind=8) D.731;
  real(kind=8) D.730;
  real(kind=8) D.729;
  real(kind=8) D.728;
  real(kind=8) D.727;

<bb 2>:
  # DEBUG iq => 2

<bb 3>:
  # iq_1 = PHI <2(2), iq_19(3)>
  # DEBUG iq => iq_1
  D.727_3 = (real(kind=8)) iq_1;
  D.728_4 = D.727_3 - 1.5e+0;
  D.729_5 = ((D.728_4));
  aq_6 = 1.0e+0 / D.729_5;
  # DEBUG aq => aq_6
  # DEBUG aqdot => aq_6 * adotoa_7(D)
  D.730_9 = __builtin_pow (aq_6, 2.0e+0);
  D.731_10 = D.730_9 + 1.0e+0;
  D.719_11 = ((D.731_10));
  D.733_13 = __builtin_pow (D.719_11, -1.5e+0);
  aqdot_8 = D.733_13 * adotoa_7(D);
  D.732_12 = aqdot_8 * aq_6;
  D.734_14 = D.732_12 * aq_6;
  vdot_15 = -D.734_14;
  # DEBUG vdot => vdot_15
  D.735_16 = (integer(kind=8)) iq_1;
  D.736_17 = D.735_16 + -1;
  g1[D.736_17] = vdot_15;
  iq_19 = iq_1 + 1;
  # DEBUG iq => iq_19
  if (iq_1 == 4)
    goto <bb 4>;
  else
    goto <bb 3>;

<bb 4>:
  dummy (&g1);
  return;

}


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

* [Bug rtl-optimization/49472] [4.7 regression] Compiler segfault on valid code
  2011-06-20 11:05 [Bug fortran/49472] New: [gfortran, 4.7 regression] Compiler segfault on valid code martin@mpa-garching.mpg.de
                   ` (5 preceding siblings ...)
  2011-06-20 15:18 ` wschmidt at gcc dot gnu.org
@ 2011-06-20 15:19 ` wschmidt at gcc dot gnu.org
  2011-06-20 16:09 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2011-06-20 15:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2011-06-20 15:18:55 UTC ---
Sorry, paste error.  That was the wrong gimple dump.  HERE is 142.optimized:

;; Function nu_derivs (__massivenu_MOD_nu_derivs, funcdef_no=0, decl_uid=708,
cgraph_uid=0)

nu_derivs ()
{
  void * D.760;
  <unnamed-unsigned:64> ivtmp.14;
  real(kind=8) powroot.4;
  real(kind=8) powmult.2;
  real(kind=8) D.719;
  real(kind=8) vdot;
  integer(kind=4) iq;
  real(kind=8) g1[4];
  real(kind=8) aqdot;
  real(kind=8) aq;
  real(kind=8) adotoa;
  real(kind=8) D.734;
  real(kind=8) D.732;
  real(kind=8) D.731;
  real(kind=8) D.729;
  real(kind=8) D.728;
  real(kind=8) D.727;

<bb 2>:
  # DEBUG iq => 2
  ivtmp.14_31 = (<unnamed-unsigned:64>) &g1[0];

<bb 3>:
  # iq_1 = PHI <2(2), iq_19(3)>
  # ivtmp.14_29 = PHI <ivtmp.14_31(2), ivtmp.14_30(3)>
  # DEBUG iq => iq_1
  D.727_3 = (real(kind=8)) iq_1;
  D.728_4 = D.727_3 - 1.5e+0;
  D.729_5 = ((D.728_4));
  aq_6 = 1.0e+0 / D.729_5;
  # DEBUG aq => aq_6
  # DEBUG aqdot => aq_6 * adotoa_7(D)
  powmult.2_25 = aq_6 * aq_6;
  D.731_10 = powmult.2_25 + 1.0e+0;
  D.719_11 = ((D.731_10));
  powroot.4_26 = __builtin_sqrt (D.719_11);
  powroot.4_27 = D.719_11 * powroot.4_26;
  powroot.4_28 = 1.0e+0 / powroot.4_27;
  aqdot_8 = powroot.4_28 * adotoa_7(D);
  D.732_12 = aqdot_8 * aq_6;
  D.734_14 = D.732_12 * aq_6;
  vdot_15 = -D.734_14;
  # DEBUG vdot => vdot_15
  ivtmp.14_30 = ivtmp.14_29 + 8;
  D.760_32 = (void *) ivtmp.14_30;
  MEM[base: D.760_32, offset: 0B] = vdot_15;
  iq_19 = iq_1 + 1;
  # DEBUG iq => iq_19
  if (iq_19 == 5)
    goto <bb 4>;
  else
    goto <bb 3>;

<bb 4>:
  dummy (&g1);
  return;

}


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

* [Bug rtl-optimization/49472] [4.7 regression] Compiler segfault on valid code
  2011-06-20 11:05 [Bug fortran/49472] New: [gfortran, 4.7 regression] Compiler segfault on valid code martin@mpa-garching.mpg.de
                   ` (6 preceding siblings ...)
  2011-06-20 15:19 ` wschmidt at gcc dot gnu.org
@ 2011-06-20 16:09 ` jakub at gcc dot gnu.org
  2011-06-21  7:52 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-06-20 16:09 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aoliva at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-06-20 16:07:45 UTC ---
We seem to be oscillating on
exprA = (div:DF (reg:DF 98) (reg:DF 96))
exprB = (div:DF (const_double:DF 1.0e+0 [0x0.8p+1]) (reg:DF 90 [ powroot.4 ]))

op0:
(mult:DF exprA (neg:DF exprA))
op1:
exprB

and:
op0:
(mult:DF exprB (neg:DF exprA))
op1:
exprA

and:
op0:
(mult:DF exprA (neg:DF exprB))
op1:
exprA

(and then back to the first op0/op1 form) in:
1799      /* Canonicalize "(x op c) op y" as "(x op y) op c".  */
1800      if (swap_commutative_operands_p (XEXP (op0, 1), op1))
1801        {
1802          tem = simplify_gen_binary (code, mode, XEXP (op0, 0), op1);
1803          return simplify_gen_binary (code, mode, tem, XEXP (op0, 1));
1804        }

(each new occurrence of this is 7 frames deeper in the backtrace).
Not sure if this might be "fixed" by Alex' patch for PR48866 (if we generate
more debug temps, supposedly the expressions wouldn't be so large and we
wouldn't hit this.

Anyway, the issue here is that swap_commutative_operands_p thinks it is better
to have the negation in the second operand instead of second operand of the
first operand, but when we built it that way, MULT case in
simplify_binary_operation_1 attempts to move the NEG from the second operand to
the first one:
      if (GET_CODE (op1) == NEG)
        {
          rtx temp = simplify_unary_operation (NEG, mode, op0, mode);
          if (temp)
            return simplify_gen_binary (MULT, mode, temp, XEXP (op1, 0));
        }
then simplify_unary_operation_1 does:
689      /* (neg (mult A B)) becomes (mult (neg A) B).
690         This works even for floating-point values.  */
691      if (GET_CODE (op) == MULT
692          && !HONOR_SIGN_DEPENDENT_ROUNDING (mode))
693        {
694          temp = simplify_gen_unary (NEG, mode, XEXP (op, 0), mode);
695          return simplify_gen_binary (MULT, mode, temp, XEXP (op, 1));
696        }
and finally simplify_binary_operation_1 does:
1840  /* Make sure the constant is second.  */
1841  if (GET_RTX_CLASS (code) == RTX_COMM_ARITH
1842      && swap_commutative_operands_p (op0, op1))
1843    {
1844      tem = op0, op0 = op1, op1 = tem;
1845    }


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

* [Bug rtl-optimization/49472] [4.7 regression] Compiler segfault on valid code
  2011-06-20 11:05 [Bug fortran/49472] New: [gfortran, 4.7 regression] Compiler segfault on valid code martin@mpa-garching.mpg.de
                   ` (7 preceding siblings ...)
  2011-06-20 16:09 ` jakub at gcc dot gnu.org
@ 2011-06-21  7:52 ` jakub at gcc dot gnu.org
  2011-06-21  8:33 ` ebotcazou at gcc dot gnu.org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-06-21  7:52 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot
                   |                            |gnu.org

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-06-21 07:51:34 UTC ---
--- gcc/simplify-rtx.c.jj    2011-06-08 08:53:15.000000000 +0200
+++ gcc/simplify-rtx.c    2011-06-21 09:46:27.000000000 +0200
@@ -686,13 +686,13 @@ simplify_unary_operation_1 (enum rtx_cod
       return simplify_gen_binary (MINUS, mode, temp, XEXP (op, 1));
     }

-      /* (neg (mult A B)) becomes (mult (neg A) B).
+      /* (neg (mult A B)) becomes (mult A (neg B)).
      This works even for floating-point values.  */
       if (GET_CODE (op) == MULT
       && !HONOR_SIGN_DEPENDENT_ROUNDING (mode))
     {
-      temp = simplify_gen_unary (NEG, mode, XEXP (op, 0), mode);
-      return simplify_gen_binary (MULT, mode, temp, XEXP (op, 1));
+      temp = simplify_gen_unary (NEG, mode, XEXP (op, 1), mode);
+      return simplify_gen_binary (MULT, mode, XEXP (op, 0), temp);
     }

       /* NEG commutes with ASHIFT since it is multiplication.  Only do

stops the moving of the operands around, with this it keeps being called with
the same operands again and again, but still an endless recursion.  Eric, any
preferences where to prevent this from happening?


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

* [Bug rtl-optimization/49472] [4.7 regression] Compiler segfault on valid code
  2011-06-20 11:05 [Bug fortran/49472] New: [gfortran, 4.7 regression] Compiler segfault on valid code martin@mpa-garching.mpg.de
                   ` (8 preceding siblings ...)
  2011-06-21  7:52 ` jakub at gcc dot gnu.org
@ 2011-06-21  8:33 ` ebotcazou at gcc dot gnu.org
  2011-07-04 10:28 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2011-06-21  8:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-06-21 08:31:22 UTC ---
> --- gcc/simplify-rtx.c.jj    2011-06-08 08:53:15.000000000 +0200
> +++ gcc/simplify-rtx.c    2011-06-21 09:46:27.000000000 +0200
> @@ -686,13 +686,13 @@ simplify_unary_operation_1 (enum rtx_cod
>        return simplify_gen_binary (MINUS, mode, temp, XEXP (op, 1));
>      }
> 
> -      /* (neg (mult A B)) becomes (mult (neg A) B).
> +      /* (neg (mult A B)) becomes (mult A (neg B)).
>       This works even for floating-point values.  */
>        if (GET_CODE (op) == MULT
>        && !HONOR_SIGN_DEPENDENT_ROUNDING (mode))
>      {
> -      temp = simplify_gen_unary (NEG, mode, XEXP (op, 0), mode);
> -      return simplify_gen_binary (MULT, mode, temp, XEXP (op, 1));
> +      temp = simplify_gen_unary (NEG, mode, XEXP (op, 1), mode);
> +      return simplify_gen_binary (MULT, mode, XEXP (op, 0), temp);
>      }
> 
>        /* NEG commutes with ASHIFT since it is multiplication.  Only do
> 
> stops the moving of the operands around, with this it keeps being called with
> the same operands again and again, but still an endless recursion.  Eric, any
> preferences where to prevent this from happening?

ISTM that pursuing in the above way, according to swap_commutative_operands_p,
is a sensible approach, so I'd remove the simplify_binary_operation_1 bits.


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

* [Bug rtl-optimization/49472] [4.7 regression] Compiler segfault on valid code
  2011-06-20 11:05 [Bug fortran/49472] New: [gfortran, 4.7 regression] Compiler segfault on valid code martin@mpa-garching.mpg.de
                   ` (9 preceding siblings ...)
  2011-06-21  8:33 ` ebotcazou at gcc dot gnu.org
@ 2011-07-04 10:28 ` jakub at gcc dot gnu.org
  2011-07-04 18:54 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-07-04 10:28 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |jakub at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-04 10:27:23 UTC ---
Created attachment 24669
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24669
gcc47-pr49472.patch

Untested fix.


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

* [Bug rtl-optimization/49472] [4.7 regression] Compiler segfault on valid code
  2011-06-20 11:05 [Bug fortran/49472] New: [gfortran, 4.7 regression] Compiler segfault on valid code martin@mpa-garching.mpg.de
                   ` (10 preceding siblings ...)
  2011-07-04 10:28 ` jakub at gcc dot gnu.org
@ 2011-07-04 18:54 ` jakub at gcc dot gnu.org
  2011-07-04 18:57 ` jakub at gcc dot gnu.org
  2011-07-04 21:12 ` jakub at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-07-04 18:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-04 18:53:58 UTC ---
Author: jakub
Date: Mon Jul  4 18:53:56 2011
New Revision: 175821

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175821
Log:
    PR rtl-optimization/49472
    * simplify-rtx.c (simplify_unary_operation_1) <case NEG>: When
    negating MULT, negate the second operand instead of first.
    (simplify_binary_operation_1) <case MULT>: If one operand is
    a NEG and the other is MULT, don't attempt to optimize by
    negation of the MULT operand if it only moves the NEG operation
    around.

    * gfortran.dg/pr49472.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/pr49472.f90
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/simplify-rtx.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug rtl-optimization/49472] [4.7 regression] Compiler segfault on valid code
  2011-06-20 11:05 [Bug fortran/49472] New: [gfortran, 4.7 regression] Compiler segfault on valid code martin@mpa-garching.mpg.de
                   ` (11 preceding siblings ...)
  2011-07-04 18:54 ` jakub at gcc dot gnu.org
@ 2011-07-04 18:57 ` jakub at gcc dot gnu.org
  2011-07-04 21:12 ` jakub at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-07-04 18:57 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-04 18:54:51 UTC ---
Fixed.


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

* [Bug rtl-optimization/49472] [4.7 regression] Compiler segfault on valid code
  2011-06-20 11:05 [Bug fortran/49472] New: [gfortran, 4.7 regression] Compiler segfault on valid code martin@mpa-garching.mpg.de
                   ` (12 preceding siblings ...)
  2011-07-04 18:57 ` jakub at gcc dot gnu.org
@ 2011-07-04 21:12 ` jakub at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-07-04 21:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-04 21:09:28 UTC ---
Author: jakub
Date: Mon Jul  4 21:09:26 2011
New Revision: 175828

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175828
Log:
    PR rtl-optimization/49472
    * simplify-rtx.c (simplify_unary_operation_1) <case NEG>: When
    negating MULT, negate the second operand instead of first.
    (simplify_binary_operation_1) <case MULT>: If one operand is
    a NEG and the other is MULT, don't attempt to optimize by
    negation of the MULT operand if it only moves the NEG operation
    around.

    * gfortran.dg/pr49472.f90: New test.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/pr49472.f90
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/simplify-rtx.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

end of thread, other threads:[~2011-07-04 21:12 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-20 11:05 [Bug fortran/49472] New: [gfortran, 4.7 regression] Compiler segfault on valid code martin@mpa-garching.mpg.de
2011-06-20 11:31 ` [Bug fortran/49472] " dominiq at lps dot ens.fr
2011-06-20 11:55 ` [Bug rtl-optimization/49472] [4.7 " rguenth at gcc dot gnu.org
2011-06-20 12:13 ` janus at gcc dot gnu.org
2011-06-20 14:13 ` dominiq at lps dot ens.fr
2011-06-20 14:18 ` dominiq at lps dot ens.fr
2011-06-20 15:18 ` wschmidt at gcc dot gnu.org
2011-06-20 15:19 ` wschmidt at gcc dot gnu.org
2011-06-20 16:09 ` jakub at gcc dot gnu.org
2011-06-21  7:52 ` jakub at gcc dot gnu.org
2011-06-21  8:33 ` ebotcazou at gcc dot gnu.org
2011-07-04 10:28 ` jakub at gcc dot gnu.org
2011-07-04 18:54 ` jakub at gcc dot gnu.org
2011-07-04 18:57 ` jakub at gcc dot gnu.org
2011-07-04 21:12 ` jakub at gcc dot gnu.org

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).