Bug 32218 - [4.2/4.3 Regression] segfault with -O1 -ftree-vectorize
Summary: [4.2/4.3 Regression] segfault with -O1 -ftree-vectorize
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.3.0
: P1 normal
Target Milestone: 4.2.2
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2007-06-05 08:30 UTC by Martin Michlmayr
Modified: 2007-07-26 16:44 UTC (History)
6 users (show)

See Also:
Host:
Target: ia64-*-*
Build:
Known to work: 4.1.1
Known to fail: 4.2.0 4.3.0
Last reconfirmed: 2007-06-06 23:44:34


Attachments
dump file of -fdump-tree-vect-details (1.02 KB, text/plain)
2007-07-01 11:33 UTC, Martin Michlmayr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Michlmayr 2007-06-05 08:30:50 UTC
I'm getting the following segfault on IA-64 with current 4.2 and 4.3.
This goes back at least to 20060721 - I don't have anything older to
test here at the moment.  I don't see this segfault on x86_64.

Unfortunately I don't have a working gdb on ia-64 at the moment so
I cannot supply a backtrace.

tbm@coconut0:~$ /usr/lib/gcc-snapshot/bin/gcc -c -O1 -ftree-vectorize /home/tbm/poc-streamer-ogg-write.c
/home/tbm/poc-streamer-ogg-write.c: In function 'ogg_fill_page_hdr':
/home/tbm/poc-streamer-ogg-write.c:14: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.

Testcase:


typedef struct buf_s
{
  unsigned long size;
}
buf_t;
typedef struct ogg_page_s
{
  unsigned char page_segments;
  unsigned char lacing_values[255];
  buf_t raw;
}
ogg_page_t;
ogg_fill_page_hdr (ogg_page_t *page)
{
  unsigned long size = page->page_segments;
  int i;
  for (i = 0; i < page->page_segments; i++)
    size += page->lacing_values[i];
  if (page->raw.size < size)
    for (i = 0; i < page->page_segments; i++)
        continue;
}
Comment 1 dorit 2007-07-01 11:23:22 UTC
(In reply to comment #0)
> I'm getting the following segfault on IA-64 with current 4.2 and 4.3.
> This goes back at least to 20060721 - I don't have anything older to
> test here at the moment.  I don't see this segfault on x86_64.
> Unfortunately I don't have a working gdb on ia-64 at the moment so
> I cannot supply a backtrace.

Can someone with access to ia64 provide more detail? gdb backtrace? vectorizer dump file (with -fdump-tree-vect-details)? (can't reproduce it on powerpc and i386)
Comment 2 Martin Michlmayr 2007-07-01 11:32:25 UTC
(In reply to comment #1)
> Can someone with access to ia64 provide more detail? gdb backtrace? vectorizer
> dump file (with -fdump-tree-vect-details)? (can't reproduce it on powerpc and
> i386)

I'm afraid I still don't have a working gdb, but I'll attach the dump file.

Steve, can you post a backtrace?
Comment 3 Martin Michlmayr 2007-07-01 11:33:16 UTC
Created attachment 13812 [details]
dump file of -fdump-tree-vect-details
Comment 4 Steve Ellcey 2007-07-03 20:19:09 UTC
I just tried to reproduce this bug on IA64 Linux (and HP-UX) with ToT sources (version 126242) and was not able to.  Can anyone else reproduce this with ToT sources?
Comment 5 dorit 2007-07-24 08:53:31 UTC
(In reply to comment #4)
> I just tried to reproduce this bug on IA64 Linux (and HP-UX) with ToT sources
> (version 126242) and was not able to.  Can anyone else reproduce this with ToT
> sources?

does the fact that no one has responded yet means that this failure cannot be reproduced anymore?


Comment 6 Martin Michlmayr 2007-07-24 18:37:09 UTC
(In reply to comment #5)
> does the fact that no one has responded yet means that this failure cannot be
> reproduced anymore?

I'll try next week and let you know.
Comment 7 Steve Ellcey 2007-07-25 16:20:15 UTC
Well, that was silly.  I couldn't reproduce the problem because I had a patch in my local tree.  Here is the patch I created, I will submit it to gcc-patches.
Basically, get_vectype_for_scalar_type can return a NULL_TREE and we need to allow for that and not call TYPE_MODE with a NULL_TREE.

Index: tree-vect-patterns.c
===================================================================
--- tree-vect-patterns.c        (revision 126897)
+++ tree-vect-patterns.c        (working copy)
@@ -651,8 +651,9 @@ vect_pattern_recog_1 (
           || (icode = optab->handlers[(int) vec_mode].insn_code) ==
               CODE_FOR_nothing
           || (type_out
-              && (insn_data[icode].operand[0].mode !=
-                  TYPE_MODE (get_vectype_for_scalar_type (type_out)))))
+              && (!get_vectype_for_scalar_type (type_out)
+                  || (insn_data[icode].operand[0].mode !=
+                      TYPE_MODE (get_vectype_for_scalar_type (type_out))))))
        return;
     }
Comment 8 Steve Ellcey 2007-07-25 20:24:25 UTC
Subject: Bug 32218

Author: sje
Date: Wed Jul 25 20:24:15 2007
New Revision: 126931

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126931
Log:
	PR target/32218
	* tree-vect-patterns.c (vect_pattern_recog_1): Check for valid type.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-vect-patterns.c

Comment 9 Steve Ellcey 2007-07-26 16:30:37 UTC
The fix for this was approved and checked into mainline.
Comment 10 Pawel Sikora 2007-07-26 16:37:53 UTC
(In reply to comment #9)
> The fix for this was approved and checked into mainline.

resolved/fixed? what about 4.2 branch? it's a regression.
Comment 11 Steve Ellcey 2007-07-26 16:44:14 UTC
Sorry, I missed the fact that it was a regression.  I will test the 4.2 branch and then backport it.
Comment 12 Steve Ellcey 2007-07-30 15:16:09 UTC
Subject: Bug 32218

Author: sje
Date: Mon Jul 30 15:15:54 2007
New Revision: 127062

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127062
Log:
	PR target/32218
	* tree-vect-patterns.c (vect_pattern_recog_1): Check for valid type.

Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/tree-vect-patterns.c