public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/32931]  New: FORALL and WHERE give an ICE with -fdefault-integer-8 and -m64
@ 2007-07-29 17:24 dominiq at lps dot ens dot fr
  2007-07-29 19:36 ` [Bug fortran/32931] " dominiq at lps dot ens dot fr
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: dominiq at lps dot ens dot fr @ 2007-07-29 17:24 UTC (permalink / raw)
  To: gcc-bugs

I think the following is different enough from PR32770 to justify a new PR. As
reported,
gfortran.dg/forall_4.f90 and gfortran.dg/where_operator_assign_2.f90 give an
ICE
when compiled on darwin8 with both -fdefault-integer-8 and -m64 (see
PR32770#20) fo a backtrace. 

The following reduced codes yield the same ICE:

  integer, parameter :: n = 4
  integer :: i, a(n)
  logical :: s(n)
  s = .True.

  a = 0
  forall (i=1:n, .not. s(i)) a(i) = i
  if (any (a .ne. (/1,0,0,4/))) call abort ()

end

and

module global
  type :: a
    integer :: b
    integer :: c
  end type a
  interface assignment(=)
    module procedure a_to_a
  end interface
  interface operator(.ne.)
    module procedure a_ne_a
  end interface

  type(a) :: x(4), y(4), z(4), u(4, 4)
  logical :: l1(4), t = .true., f= .false.
contains
!******************************************************************************
  elemental subroutine a_to_a (m, n)
    type(a), intent(in) :: n
    type(a), intent(out) :: m
    m%b = n%b + 1
    m%c = n%c
  end subroutine a_to_a
!******************************************************************************
  elemental logical function a_ne_a (m, n)
    type(a), intent(in) :: n
    type(a), intent(in) :: m
    a_ne_a = (m%b .ne. n%b) .or. (m%c .ne. n%c)
  end function a_ne_a
!******************************************************************************
  elemental function foo (m)
    type(a) :: foo
    type(a), intent(in) :: m
    foo%b = 0
    foo%c = m%c
  end function foo  
end module global
!******************************************************************************
program test
  use global
  x = (/a (0, 1),a (0, 2),a (0, 3),a (0, 4)/)
  y = x
  z = x
  l1 = (/t, f, f, t/)

  call test_where_3
  if (any (y .ne. (/a (1, 0),a (1, 2),a (1, 3),a (1, 0)/))) call abort ()

!  y = x
!  call test_where_forall_1
!  if (any (u(4, :) .ne. (/a (1, 4),a (2, 2),a (2, 3),a (1, 4)/))) call abort
()

contains
!******************************************************************************
  subroutine test_where_3        ! Test a simple WHERE with a function
assignment
    where (.not. l1) y = foo (x)
  end subroutine test_where_3
!******************************************************************************
!  subroutine test_where_forall_1 ! Test a WHERE in a FORALL block
!    forall (i = 1:4)
!      where (.not. l1)
!        u(i, :) = x
!      elsewhere
!        u(i, :) = a(0, i)
!      endwhere
!    end forall
!  end subroutine test_where_forall_1
!******************************************************************************
end program test 

The commented FORALL also gives the same ICE. However the simplified version of
the last code:

program test
  integer :: x(4), y(4), z(4), u(4, 4)
  logical :: l1(4), t = .true., f= .false.
  x = (/ 1, 2, 3, 4/)
  l1 = (/t, f, f, t/)

  y = 0
  where (.not. l1) y = x
  if (any (y .ne. (/0, 2, 3, 0/))) call abort ()

end program test 

compiles and pass. Note also that the problem is also present in gcc 4.2.1.


-- 
           Summary: FORALL and WHERE give an ICE with -fdefault-integer-8
                    and -m64
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dominiq at lps dot ens dot fr
GCC target triplet: powerpc-apple-darwin8


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


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

* [Bug fortran/32931] FORALL and WHERE give an ICE with -fdefault-integer-8 and -m64
  2007-07-29 17:24 [Bug fortran/32931] New: FORALL and WHERE give an ICE with -fdefault-integer-8 and -m64 dominiq at lps dot ens dot fr
@ 2007-07-29 19:36 ` dominiq at lps dot ens dot fr
  2007-08-08 17:06 ` fxcoudert at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dominiq at lps dot ens dot fr @ 2007-07-29 19:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from dominiq at lps dot ens dot fr  2007-07-29 19:35 -------
Note that the ICEs with -m64 diasppear with -O3, but then both tests fail to
execute.


-- 


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


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

* [Bug fortran/32931] FORALL and WHERE give an ICE with -fdefault-integer-8 and -m64
  2007-07-29 17:24 [Bug fortran/32931] New: FORALL and WHERE give an ICE with -fdefault-integer-8 and -m64 dominiq at lps dot ens dot fr
  2007-07-29 19:36 ` [Bug fortran/32931] " dominiq at lps dot ens dot fr
@ 2007-08-08 17:06 ` fxcoudert at gcc dot gnu dot org
  2007-10-05 13:02 ` fxcoudert at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-08-08 17:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from fxcoudert at gcc dot gnu dot org  2007-08-08 17:05 -------
Target specific, I can't reproduce it on x86_64-linux, with both -m32 and -m64,
even when using valgrind.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fxcoudert at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-08-08 17:05:45
               date|                            |


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


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

* [Bug fortran/32931] FORALL and WHERE give an ICE with -fdefault-integer-8 and -m64
  2007-07-29 17:24 [Bug fortran/32931] New: FORALL and WHERE give an ICE with -fdefault-integer-8 and -m64 dominiq at lps dot ens dot fr
  2007-07-29 19:36 ` [Bug fortran/32931] " dominiq at lps dot ens dot fr
  2007-08-08 17:06 ` fxcoudert at gcc dot gnu dot org
@ 2007-10-05 13:02 ` fxcoudert at gcc dot gnu dot org
  2007-11-03 13:00 ` [Bug fortran/32931] FORALL and WHERE give an ICE with -m64 fxcoudert at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-10-05 13:02 UTC (permalink / raw)
  To: gcc-bugs



-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |fxcoudert at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
           Keywords|                            |ice-on-valid-code
   Last reconfirmed|2007-08-08 17:05:45         |2007-10-05 13:02:36
               date|                            |


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


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

* [Bug fortran/32931] FORALL and WHERE give an ICE with -m64
  2007-07-29 17:24 [Bug fortran/32931] New: FORALL and WHERE give an ICE with -fdefault-integer-8 and -m64 dominiq at lps dot ens dot fr
                   ` (2 preceding siblings ...)
  2007-10-05 13:02 ` fxcoudert at gcc dot gnu dot org
@ 2007-11-03 13:00 ` fxcoudert at gcc dot gnu dot org
  2007-11-03 18:46 ` [Bug middle-end/32931] " pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-11-03 13:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from fxcoudert at gcc dot gnu dot org  2007-11-03 13:00 -------
  integer i, a(1)
  logical(kind=8) s(1)

  s = .true.
  a = 42
  forall (i=1:1, .not. s(1)) a(i) = 0
  end


The ICE happens because we return false in validate_subreg(), called from
gen_rtx_SUBREG(). We come into validate_subreg() with omode=SImode,
imode=DImode, offset=0 and and reg is (reg:DI 130 [ D.975 ]).

We then go to the end of that function, to the following code:

  /* For pseudo registers, we want most of the same checks.  Namely:
     If the register no larger than a word, the subreg must be lowpart.
     If the register is larger than a word, the subreg must be the lowpart
     of a subword.  A subreg does *not* perform arbitrary bit extraction.
     Given that we've already checked mode/offset alignment, we only have
     to check subword subregs here.  */
  if (osize < UNITS_PER_WORD)
    { 
      enum machine_mode wmode = isize > UNITS_PER_WORD ? word_mode : imode;
      unsigned int low_off = subreg_lowpart_offset (omode, wmode);
      if (offset % UNITS_PER_WORD != low_off)
        return false;
    }

and we have wmode = DImode, low_off = 4, and thus we fail the check. The code
that leads to this is:

  logical8 s[1];
  logical1 D.976;
  logical8 D.975;

  D.975 = s[0];
  D.976 = !D.975;

Now, this testcase doesn't trigger an ICE on x86_64-linux, even with
type-checking on, so I'm wondering if this might be a target problem.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|FORALL and WHERE give an ICE|FORALL and WHERE give an ICE
                   |with -fdefault-integer-8 and|with -m64
                   |-m64                        |


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


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

* [Bug middle-end/32931] FORALL and WHERE give an ICE with -m64
  2007-07-29 17:24 [Bug fortran/32931] New: FORALL and WHERE give an ICE with -fdefault-integer-8 and -m64 dominiq at lps dot ens dot fr
                   ` (3 preceding siblings ...)
  2007-11-03 13:00 ` [Bug fortran/32931] FORALL and WHERE give an ICE with -m64 fxcoudert at gcc dot gnu dot org
@ 2007-11-03 18:46 ` pinskia at gcc dot gnu dot org
  2007-11-03 18:52 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-11-03 18:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2007-11-03 18:46 -------
Hmm:
  D.561 = s[0];
  D.562 = !D.561;
  temp.4[mi.8] = D.562;

  logical8 D.561;
  logical1 D.562;

So we have a TRUTH_NOT_EXPR of a logical8 and that has an implicated cast to
logical1.  So this is either a front-end bug or a middle-end (in fold or
gimplifier).  I want to say fold as we go from:
      D.562 = D.561 == 0;

To:
  D.562 = !D.561;


And I think this is my fault too so assigning this to me.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|fxcoudert at gcc dot gnu dot|pinskia at gcc dot gnu dot
                   |org                         |org
          Component|fortran                     |middle-end


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


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

* [Bug middle-end/32931] FORALL and WHERE give an ICE with -m64
  2007-07-29 17:24 [Bug fortran/32931] New: FORALL and WHERE give an ICE with -fdefault-integer-8 and -m64 dominiq at lps dot ens dot fr
                   ` (4 preceding siblings ...)
  2007-11-03 18:46 ` [Bug middle-end/32931] " pinskia at gcc dot gnu dot org
@ 2007-11-03 18:52 ` pinskia at gcc dot gnu dot org
  2007-11-04 19:05 ` pinskia at gcc dot gnu dot org
  2007-11-04 19:05 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-11-03 18:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2007-11-03 18:52 -------
The patch to fix the bug:
Index: ../../gcc/fold-const.c
===================================================================
--- ../../gcc/fold-const.c      (revision 129871)
+++ ../../gcc/fold-const.c      (working copy)
@@ -11709,12 +11709,12 @@ fold_binary (enum tree_code code, tree t
       /* bool_var != 1 becomes !bool_var. */
       if (TREE_CODE (TREE_TYPE (arg0)) == BOOLEAN_TYPE && integer_onep (arg1)
           && code == NE_EXPR)
-        return fold_build1 (TRUTH_NOT_EXPR, type, arg0);
+        return fold_build1 (TRUTH_NOT_EXPR, type, fold_convert (type, arg0));

       /* bool_var == 0 becomes !bool_var. */
       if (TREE_CODE (TREE_TYPE (arg0)) == BOOLEAN_TYPE && integer_zerop (arg1)
           && code == EQ_EXPR)
-        return fold_build1 (TRUTH_NOT_EXPR, type, arg0);
+        return fold_build1 (TRUTH_NOT_EXPR, type, fold_convert (type, arg0));

       /* If this is an equality comparison of the address of two non-weak,
         unaliased symbols neither of which are extern (since we do not


-- 


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


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

* [Bug middle-end/32931] FORALL and WHERE give an ICE with -m64
  2007-07-29 17:24 [Bug fortran/32931] New: FORALL and WHERE give an ICE with -fdefault-integer-8 and -m64 dominiq at lps dot ens dot fr
                   ` (6 preceding siblings ...)
  2007-11-04 19:05 ` pinskia at gcc dot gnu dot org
@ 2007-11-04 19:05 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-11-04 19:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2007-11-04 19:05 -------
All fixed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


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

* [Bug middle-end/32931] FORALL and WHERE give an ICE with -m64
  2007-07-29 17:24 [Bug fortran/32931] New: FORALL and WHERE give an ICE with -fdefault-integer-8 and -m64 dominiq at lps dot ens dot fr
                   ` (5 preceding siblings ...)
  2007-11-03 18:52 ` pinskia at gcc dot gnu dot org
@ 2007-11-04 19:05 ` pinskia at gcc dot gnu dot org
  2007-11-04 19:05 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-11-04 19:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2007-11-04 19:05 -------
Subject: Bug 32931

Author: pinskia
Date: Sun Nov  4 19:04:49 2007
New Revision: 129886

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129886
Log:
2007-11-04  Andrew Pinski  <pinskia@gmail.com>

        PR middle-end/32931
        * fold-const.c (fold_binary <case EQ_EXPR>): Convert the inner type
        for TRUTH_NOT_EXPR to type.

2007-11-04  Andrew Pinski  <pinskia@gmail.com>

        PR middle-end/32931
        * gfortran.fortran-torture/compile/forall-1.f90: New testcase.


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


-- 


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


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

end of thread, other threads:[~2007-11-04 19:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-29 17:24 [Bug fortran/32931] New: FORALL and WHERE give an ICE with -fdefault-integer-8 and -m64 dominiq at lps dot ens dot fr
2007-07-29 19:36 ` [Bug fortran/32931] " dominiq at lps dot ens dot fr
2007-08-08 17:06 ` fxcoudert at gcc dot gnu dot org
2007-10-05 13:02 ` fxcoudert at gcc dot gnu dot org
2007-11-03 13:00 ` [Bug fortran/32931] FORALL and WHERE give an ICE with -m64 fxcoudert at gcc dot gnu dot org
2007-11-03 18:46 ` [Bug middle-end/32931] " pinskia at gcc dot gnu dot org
2007-11-03 18:52 ` pinskia at gcc dot gnu dot org
2007-11-04 19:05 ` pinskia at gcc dot gnu dot org
2007-11-04 19:05 ` pinskia at gcc dot gnu dot 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).