Bug 69264 - [5 regression] ICE building spidermonkey -mcpu=970 -maltivec -O3: rs6000_builtin_vectorization_cost, at config/rs6000/rs6000.c:4350
Summary: [5 regression] ICE building spidermonkey -mcpu=970 -maltivec -O3: rs6000_buil...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 5.3.0
: P2 normal
Target Milestone: 6.0
Assignee: Richard Biener
URL: https://bugs.gentoo.org/571482
Keywords:
Depends on: 79256
Blocks:
  Show dependency treegraph
 
Reported: 2016-01-13 17:00 UTC by Mike Frysinger
Modified: 2017-10-10 14:56 UTC (History)
4 users (show)

See Also:
Host:
Target: powerpc64*-linux-gnu
Build:
Known to work: 4.8.5, 6.3.1, 7.0
Known to fail: 4.9.3, 5.3.0, 6.3.0
Last reconfirmed: 2016-01-21 00:00:00


Attachments
reduced testcase (551 bytes, text/plain)
2016-01-13 17:00 UTC, Mike Frysinger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Frysinger 2016-01-13 17:00:47 UTC
Created attachment 37334 [details]
reduced testcase

building spidermonkey on ppc64 w/-maltivec -O3 fails starting w/gcc-4.9:
powerpc64-unknown-linux-gnu-g++ -o jsxml.o -c  -fvisibility=hidden -DOSTYPE=\"Linux4.1\" -DOSARCH=Linux -DEXPORT_JS_API -D__STDC_LIMIT_MACROS  -I. -I. -I./dist/include -I./dist/include/nsprpub  -I/usr/include/nspr   -I. -I./assembler -I./yarr  -fPIC  -fno-rtti -fno-exceptions -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align -Wno-invalid-offsetof -Wno-variadic-macros -Werror=return-type -pedantic -Wno-long-long -mcpu=970 -mtune=970 -O2 -maltivec -mabi=altivec -pipe -fno-strict-aliasing -pthread -pipe  -DNDEBUG -DTRIMMED -O3 -fstrict-aliasing -fomit-frame-pointer -DUSE_SYSTEM_MALLOC=1 -DENABLE_ASSEMBLER=1 -DENABLE_JIT=1   -DMOZILLA_CLIENT -include ./js-confdefs.h -MD -MF .deps/jsxml.pp jsxml.cpp
...
internal compiler error: in rs6000_builtin_vectorization_cost, at config/rs6000/rs6000.c:4350
...

reduced test case is attached.  ICE is observed with 4.9.3 & 5.3.0.  4.8.5 works fine though.
$ powerpc64-unknown-linux-gnu-g++-4.9.3 -O3 -maltivec -c jsxml.ii
jsxml.ii: In function ‘void xml_defineProperty(JSContext*, int, const Value*)’:
jsxml.ii:74:6: internal compiler error: in rs6000_builtin_vectorization_cost, at config/rs6000/rs6000.c:4350
 void xml_defineProperty(JSContext *cx, int id, const Value *v)
      ^
Comment 1 Martin Sebor 2016-01-21 19:24:12 UTC
Confirmed with yesterday's trunk on both powerpc64 and powerpc64le.  The  -mcpu=970 option is also important.

$ /build/gcc-trunk/gcc/xgcc -B /build/gcc-trunk/gcc -Wall -maltivec -mcpu=970 -O3 -xc++ t.c
t.c: In function ‘jsval_layout STRING_TO_JSVAL_IMPL()’:
t.c:4:45: warning: no return statement in function returning non-void [-Wreturn-type]
 static jsval_layout STRING_TO_JSVAL_IMPL() {}
                                             ^

t.c: In function ‘Value IdToValue(int)’:
t.c:39:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^

t.c: In function ‘void PutProperty(JSContext*, int, jsval*)’:
t.c:71:30: warning: ‘nameobj’ is used uninitialized in this function [-Wuninitialized]
  nameobj->getQNameLocalName();
                              ^

t.c: In function ‘void xml_defineProperty(JSContext*, int, const Value*)’:
t.c:74:6: internal compiler error: in rs6000_builtin_vectorization_cost, at config/rs6000/rs6000.c:5105
 void xml_defineProperty(JSContext *cx, int id, const Value *v)
      ^~~~~~~~~~~~~~~~~~

0x115a776f rs6000_builtin_vectorization_cost
	/src/gcc/trunk/gcc/config/rs6000/rs6000.c:5105
0x1142e5b7 builtin_vectorization_cost
	/src/gcc/trunk/gcc/tree-vectorizer.h:835
0x1142e8bb record_stmt_cost(vec<stmt_info_for_cost, va_heap, vl_ptr>*, int, vect_cost_for_stmt, _stmt_vec_info*, int, vect_cost_model_location)
	/src/gcc/trunk/gcc/tree-vect-stmts.c:98
0x114310eb vect_get_store_cost(data_reference*, int, unsigned int*, vec<stmt_info_for_cost, va_heap, vl_ptr>*)
	/src/gcc/trunk/gcc/tree-vect-stmts.c:1023
0x11430eaf vect_model_store_cost(_stmt_vec_info*, int, bool, vect_def_type, _slp_tree*, vec<stmt_info_for_cost, va_heap, vl_ptr>*, vec<stmt_info_for_cost, va_heap, vl_ptr>*)
	/src/gcc/trunk/gcc/tree-vect-stmts.c:980
0x1147ecab vect_analyze_slp_cost_1
	/src/gcc/trunk/gcc/tree-vect-slp.c:1493
0x1147f46f vect_analyze_slp_cost
	/src/gcc/trunk/gcc/tree-vect-slp.c:1619
0x11481ca3 vect_slp_analyze_operations(vec<_slp_instance*, va_heap, vl_ptr>, void*)
	/src/gcc/trunk/gcc/tree-vect-slp.c:2355
0x114828ef vect_slp_analyze_bb_1
	/src/gcc/trunk/gcc/tree-vect-slp.c:2627
0x11482ce3 vect_slp_bb(basic_block_def*)
	/src/gcc/trunk/gcc/tree-vect-slp.c:2713
0x1148dd5b execute
	/src/gcc/trunk/gcc/tree-vectorizer.c:759
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 2 Richard Biener 2016-08-03 11:52:38 UTC
GCC 4.9 branch is being closed
Comment 3 Jakub Jelinek 2017-01-24 14:55:21 UTC
This is a consequence of the r198767 change IMHO, which changed:
@@ -4736,9 +4730,10 @@
       if (!known_alignment_for_access_p (dr))
 	is_packed = not_size_aligned (DR_REF (dr));
 
-     if (targetm.vectorize.
-         support_vector_misalignment (mode, type,
-				      DR_MISALIGNMENT (dr), is_packed))
+     if ((TYPE_USER_ALIGN (type) && !is_packed)
+	 || targetm.vectorize.
+	      support_vector_misalignment (mode, type,
+					   DR_MISALIGNMENT (dr), is_packed))
        return dr_unaligned_supported;
     }
 
i.e. the support_vector_misalignment target hook is not even considered when TYPE_USER_ALIGN (type), which is this case.  Richard, that was your change, can you please have a look?  Either the backends need to accept that even when they return false in support_vector_misalignment, it might be asked for costs of some misaligned load (and thus should not assert it will not happen, but instead say return very high cost), or the r198767 change was wrong, or we need to ask if support_vector_misalignment decision is an optimization decision or ISA decision, if it is just optimization decision, TYPE_USER_ALIGN could override it, while if it is ISA decision, it should not.
Comment 4 Richard Biener 2017-01-25 08:03:47 UTC
I will have a look.
Comment 5 Richard Biener 2017-01-25 12:31:14 UTC
Author: rguenth
Date: Wed Jan 25 12:30:41 2017
New Revision: 244897

URL: https://gcc.gnu.org/viewcvs?rev=244897&root=gcc&view=rev
Log:
2017-01-25  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/69264
	* target.def (vector_alignment_reachable): Improve documentation.
	* doc/tm.texi: Regenerate.
	* targhooks.c (default_builtin_vector_alignment_reachable): Simplify
	and add a comment.
	* tree-vect-data-refs.c (vect_supportable_dr_alignment): Revert
	earlier changes with respect to TYPE_USER_ALIGN.
	(vector_alignment_reachable_p): Likewise.  Improve dumping.

	* g++.dg/torture/pr69264.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/torture/pr69264.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/doc/tm.texi
    trunk/gcc/target.def
    trunk/gcc/targhooks.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vect-data-refs.c
Comment 6 Richard Biener 2017-01-25 13:23:08 UTC
Fixed on trunk sofar.
Comment 7 Richard Biener 2017-06-22 07:22:45 UTC
Author: rguenth
Date: Thu Jun 22 07:22:13 2017
New Revision: 249498

URL: https://gcc.gnu.org/viewcvs?rev=249498&root=gcc&view=rev
Log:
2017-06-22  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2017-01-30  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/79256
	* targhooks.c (default_builtin_vector_alignment_reachable): Honor
	BIGGEST_FIELD_ALIGNMENT and ADJUST_FIELD_ALIGN to fix up bogus
	alignment on TYPE.
	* tree.c (build_aligned_type): Set TYPE_USER_ALIGN.

	2017-01-25  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/69264
	* target.def (vector_alignment_reachable): Improve documentation.
	* doc/tm.texi: Regenerate.
	* targhooks.c (default_builtin_vector_alignment_reachable): Simplify
	and add a comment.
	* tree-vect-data-refs.c (vect_supportable_dr_alignment): Revert
	earlier changes with respect to TYPE_USER_ALIGN.
	(vector_alignment_reachable_p): Likewise.  Improve dumping.

	* g++.dg/torture/pr69264.C: New testcase.

	2017-02-09  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/69823
	* graphite-scop-detection.c (scop_detection::harmful_loop_in_region):
	Properly enumerate all BBs in the region.  Use auto_vec.

	* gcc.dg/graphite/pr69823.c: New testcase.

Added:
    branches/gcc-6-branch/gcc/testsuite/g++.dg/torture/pr69264.C
    branches/gcc-6-branch/gcc/testsuite/gcc.dg/graphite/pr69823.c
Modified:
    branches/gcc-6-branch/gcc/ChangeLog
    branches/gcc-6-branch/gcc/doc/tm.texi
    branches/gcc-6-branch/gcc/graphite-scop-detection.c
    branches/gcc-6-branch/gcc/target.def
    branches/gcc-6-branch/gcc/targhooks.c
    branches/gcc-6-branch/gcc/testsuite/ChangeLog
    branches/gcc-6-branch/gcc/tree-vect-data-refs.c
    branches/gcc-6-branch/gcc/tree.c
Comment 8 Jakub Jelinek 2017-10-10 14:22:03 UTC
GCC 5 branch has been closed, should be fixed in GCC 6 and later.