public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/46805] New: ICE: SIGSEGV in optab_for_tree_code (optabs.c:407) with -O -fno-tree-scev-cprop -ftree-vectorize
@ 2010-12-05  0:14 zsojka at seznam dot cz
  2010-12-05 11:07 ` [Bug tree-optimization/46805] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: zsojka at seznam dot cz @ 2010-12-05  0:14 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: ICE: SIGSEGV in optab_for_tree_code (optabs.c:407)
                    with -O -fno-tree-scev-cprop -ftree-vectorize
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: zsojka@seznam.cz


Created attachment 22635
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22635
reduced testcase

valgrind output:
$ gcc -O -fno-tree-scev-cprop -ftree-vectorize pr46805.go
==28234== Conditional jump or move depends on uninitialised value(s)
==28234==    at 0x595C61: Lex::require_line() (lex.cc:501)
==28234==    by 0x597E1A: Lex::next_token() (lex.cc:544)
==28234==    by 0x598532: Parse::peek_token() (parse.cc:64)
==28234==    by 0x59A08A: Parse::package_clause() (parse.cc:4544)
==28234==    by 0x5A6F7D: Parse::program() (parse.cc:4624)
==28234==    by 0x5717AC: go_parse_input_files (go.cc:82)
==28234==    by 0x91B4F7: toplev_main (toplev.c:579)
==28234==    by 0x65EABBC: (below main) (in /lib64/libc-2.11.2.so)
==28234==  Uninitialised value was created by a stack allocation
==28234==    at 0x56E720: go_langhook_parse_file (go-lang.c:222)
==28234== 
==28234== Invalid read of size 2
==28234==    at 0x8153C0: optab_for_tree_code (optabs.c:407)
==28234==    by 0xA56359: supportable_widening_operation
(tree-vect-stmts.c:5521)
==28234==    by 0xA56B45: vectorizable_type_promotion (tree-vect-stmts.c:3177)
==28234==    by 0xA596E3: vect_analyze_stmt (tree-vect-stmts.c:4697)
==28234==    by 0xA6522E: vect_analyze_loop (tree-vect-loop.c:1249)
==28234==    by 0xA71968: vectorize_loops (tree-vectorizer.c:199)
==28234==    by 0x8316FE: execute_one_pass (passes.c:1553)
==28234==    by 0x8319C4: execute_pass_list (passes.c:1608)
==28234==    by 0x8319D6: execute_pass_list (passes.c:1609)
==28234==    by 0x8319D6: execute_pass_list (passes.c:1609)
==28234==    by 0x971B45: tree_rest_of_compilation (tree-optimize.c:422)
==28234==    by 0xB374E1: cgraph_expand_function (cgraphunit.c:1508)
==28234==    by 0xB39AB9: cgraph_optimize (cgraphunit.c:1567)
==28234==    by 0xB3A039: cgraph_finalize_compilation_unit (cgraphunit.c:1031)
==28234==    by 0x57B97B: Gogo::write_globals() (gogo-tree.cc:825)
==28234==    by 0x91B535: toplev_main (toplev.c:591)
==28234==    by 0x65EABBC: (below main) (in /lib64/libc-2.11.2.so)
==28234==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==28234== 
pr46805.go: In function 'main.main':
pr46805.go:3:1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

The first failure is most likely unrelated, similiar problems can be seen for
other frontends as well.

Tested revisions:
r167453 - crash


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

* [Bug tree-optimization/46805] ICE: SIGSEGV in optab_for_tree_code (optabs.c:407) with -O -fno-tree-scev-cprop -ftree-vectorize
  2010-12-05  0:14 [Bug tree-optimization/46805] New: ICE: SIGSEGV in optab_for_tree_code (optabs.c:407) with -O -fno-tree-scev-cprop -ftree-vectorize zsojka at seznam dot cz
@ 2010-12-05 11:07 ` rguenth at gcc dot gnu.org
  2010-12-05 11:19 ` zsojka at seznam dot cz
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2010-12-05 11:07 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2010.12.05 11:07:21
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2010-12-05 11:07:21 UTC ---
A non-Go testcase would be nice ...

#1  0x0000000100b3ce41 in supportable_widening_operation (code=NOP_EXPR, 
    stmt=0x141d3d0a0, vectype_out=0x141d3cdc8, vectype_in=0x141d3cf18, 
    decl1=0x7fff5fbff1d0, decl2=0x7fff5fbff1c8, code1=0x7fff5fbff238, 
    code2=0x7fff5fbff234, multi_step_cvt=0x7fff5fbff218, 
    interm_types=0x7fff5fbff170) at ../../src/trunk/gcc/tree-vect-stmts.c:5521
5521              optab3 = optab_for_tree_code (c1, intermediate_type,
optab_default);
(gdb) p intermediate_type
$1 = (tree) 0x0


      for (i = 0; i < 3; i++)
        {
          intermediate_mode = insn_data[icode1].operand[0].mode;
          intermediate_type = lang_hooks.types.type_for_mode
(intermediate_mode,
                                                     TYPE_UNSIGNED
(prev_type));
          optab3 = optab_for_tree_code (c1, intermediate_type, optab_default);

lang_hooks.types.type_for_mode can return NULL, there is no suitable hook
that will a) return non-NULL always, b) always returns a type for the requested
mode(!)

I doubt a non-Go testcase exists.

Ideally we'd never use lang_hooks.types.type_for_mode (or _for_size) in the
middle-end but had a pure middle-end based implementation.  A manual
middle-end substitute would be

  build_nonstandard_integer_type (GET_MODE_PRECISION (intermediate_mode),
                                  TYPE_UNSIGNED (prev_type));

More uses of type_for_mode exist.

With the vectorizer bits fixed we fall into tree-vect-generic.c which does

577       else
578         /* There is no operation in hardware, so fall back to scalars.  */
579         compute_type = TREE_TYPE (type);

where type is already a TImode integer (and TREE_TYPE of it is NULL).

This is because appearantly Go has a DImode integer type but not a SImode
one.  Huh.  So we have

V2DI = VEC_UNPACK_LO_EXPR <TI>

where the TImode rhs is really V4SI.

The generic vector lowering code is confused by this.

Go -> low priority.

The following vectorizer patch leads to the above failure:

Index: tree-vect-stmts.c
===================================================================
--- tree-vect-stmts.c    (revision 167471)
+++ tree-vect-stmts.c    (working copy)
@@ -5516,7 +5516,7 @@
       for (i = 0; i < 3; i++)
         {
           intermediate_mode = insn_data[icode1].operand[0].mode;
-          intermediate_type = lang_hooks.types.type_for_mode
(intermediate_mode,
+          intermediate_type = build_nonstandard_integer_type
(GET_MODE_PRECISION (intermediate_mode),
                                                      TYPE_UNSIGNED
(prev_type));
           optab3 = optab_for_tree_code (c1, intermediate_type, optab_default);
           optab4 = optab_for_tree_code (c2, intermediate_type, optab_default);
@@ -5637,7 +5637,7 @@
       for (i = 0; i < 3; i++)
         {
           intermediate_mode = insn_data[icode1].operand[0].mode;
-          intermediate_type = lang_hooks.types.type_for_mode
(intermediate_mode,
+          intermediate_type = build_nonstandard_integer_type
(GET_MODE_PRECISION (intermediate_mode),
                                                      TYPE_UNSIGNED
(prev_type));
           interm_optab = optab_for_tree_code (c1, intermediate_type,
                                               optab_default);


another fix would be to catch intermediate_type == NULL here and fail
vectorization (but using the langhook is wrong here anyways).

Confirmed at least.


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

* [Bug tree-optimization/46805] ICE: SIGSEGV in optab_for_tree_code (optabs.c:407) with -O -fno-tree-scev-cprop -ftree-vectorize
  2010-12-05  0:14 [Bug tree-optimization/46805] New: ICE: SIGSEGV in optab_for_tree_code (optabs.c:407) with -O -fno-tree-scev-cprop -ftree-vectorize zsojka at seznam dot cz
  2010-12-05 11:07 ` [Bug tree-optimization/46805] " rguenth at gcc dot gnu.org
@ 2010-12-05 11:19 ` zsojka at seznam dot cz
  2010-12-07 19:29 ` ian at gcc dot gnu.org
  2010-12-07 19:32 ` ian at airs dot com
  3 siblings, 0 replies; 5+ messages in thread
From: zsojka at seznam dot cz @ 2010-12-05 11:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Zdenek Sojka <zsojka at seznam dot cz> 2010-12-05 11:19:08 UTC ---
Created attachment 22641
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22641
C-ified, but doesn't crash

Actually I tried to C-ify the testcase, but it no longer crashes. Maybe I
overlooked something...


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

* [Bug tree-optimization/46805] ICE: SIGSEGV in optab_for_tree_code (optabs.c:407) with -O -fno-tree-scev-cprop -ftree-vectorize
  2010-12-05  0:14 [Bug tree-optimization/46805] New: ICE: SIGSEGV in optab_for_tree_code (optabs.c:407) with -O -fno-tree-scev-cprop -ftree-vectorize zsojka at seznam dot cz
  2010-12-05 11:07 ` [Bug tree-optimization/46805] " rguenth at gcc dot gnu.org
  2010-12-05 11:19 ` zsojka at seznam dot cz
@ 2010-12-07 19:29 ` ian at gcc dot gnu.org
  2010-12-07 19:32 ` ian at airs dot com
  3 siblings, 0 replies; 5+ messages in thread
From: ian at gcc dot gnu.org @ 2010-12-07 19:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from ian at gcc dot gnu.org <ian at gcc dot gnu.org> 2010-12-07 19:28:49 UTC ---
Author: ian
Date: Tue Dec  7 19:28:44 2010
New Revision: 167563

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=167563
Log:
    PR tree-optimization/46805
    PR tree-optimization/46833
    * go-lang.c (go_langhook_type_for_mode): Handle vector modes.

Modified:
    trunk/gcc/go/ChangeLog
    trunk/gcc/go/go-lang.c


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

* [Bug tree-optimization/46805] ICE: SIGSEGV in optab_for_tree_code (optabs.c:407) with -O -fno-tree-scev-cprop -ftree-vectorize
  2010-12-05  0:14 [Bug tree-optimization/46805] New: ICE: SIGSEGV in optab_for_tree_code (optabs.c:407) with -O -fno-tree-scev-cprop -ftree-vectorize zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2010-12-07 19:29 ` ian at gcc dot gnu.org
@ 2010-12-07 19:32 ` ian at airs dot com
  3 siblings, 0 replies; 5+ messages in thread
From: ian at airs dot com @ 2010-12-07 19:32 UTC (permalink / raw)
  To: gcc-bugs

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

Ian Lance Taylor <ian at airs dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |ian at airs dot com
         Resolution|                            |FIXED

--- Comment #4 from Ian Lance Taylor <ian at airs dot com> 2010-12-07 19:32:31 UTC ---
This should work now.


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

end of thread, other threads:[~2010-12-07 19:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-05  0:14 [Bug tree-optimization/46805] New: ICE: SIGSEGV in optab_for_tree_code (optabs.c:407) with -O -fno-tree-scev-cprop -ftree-vectorize zsojka at seznam dot cz
2010-12-05 11:07 ` [Bug tree-optimization/46805] " rguenth at gcc dot gnu.org
2010-12-05 11:19 ` zsojka at seznam dot cz
2010-12-07 19:29 ` ian at gcc dot gnu.org
2010-12-07 19:32 ` ian at airs dot com

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