This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/40348] New: Powerpc spe segfaults in vectorizing powf (a[i], 0.5f)
- From: "meissner at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Jun 2009 21:16:54 -0000
- Subject: [Bug tree-optimization/40348] New: Powerpc spe segfaults in vectorizing powf (a[i], 0.5f)
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I was testing the power7 changes by building a powerpc-spe-eabi compiler to
make sure I hadn't broken anything, and I trying compiling a vector test that I
have that does almost all operations and sees whether the compiler vectorizes
it. When I compile the tests of power (a[i], 0.5f), which is supposed to
optimize the code into sqrt with -O3 and -ffast-math, the compiler segfaults.
This case fails for the mainline as well as my branch.
-etna-> gdb cc1
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "ppc-suse-linux"...
Using host libthread_db library "/lib/power6/libthread_db.so.1".
Breakpoint 1 at 0x1019e678: file /home/meissner/fsf-src/trunk/gcc/diagnostic.c,
line 730.
Breakpoint 2 at 0x1019e5d4: file /home/meissner/fsf-src/trunk/gcc/diagnostic.c,
line 670.
Breakpoint 3 at 0x108b1af0
Breakpoint 4 at 0x108b17f0
(gdb) r -O3 -mspe -quiet -ffast-math vect.i -o vect-O3.s
Starting program: /home/meissner/fsf-build-ppc32/trunk-spe/gcc/cc1 -O3 -mspe
-quiet -ffast-math vect.i -o vect-O3.s
Breakpoint 3 at 0xfea3298: file exit.c, line 34.
Breakpoint 4 at 0xfea1af8: file abort.c, line 50.
Program received signal SIGSEGV, Segmentation fault.
gimple_build_call (fn=0x0, nargs=1) at
/home/meissner/fsf-src/trunk/gcc/gimple.c:319
319 gcc_assert (TREE_CODE (fn) == FUNCTION_DECL || is_gimple_call_addr
(fn));
(gdb) print fn
$1 = (tree) 0x0
(gdb) list
314 {
315 va_list ap;
316 gimple call;
317 unsigned i;
318
319 gcc_assert (TREE_CODE (fn) == FUNCTION_DECL || is_gimple_call_addr
(fn));
320
321 call = gimple_build_call_1 (fn, nargs);
322
323 va_start (ap, nargs);
(gdb) list -
304
305 return call;
306 }
307
308
309 /* Build a GIMPLE_CALL statement to function FN. NARGS is the number
of
310 arguments. The ... are the arguments. */
311
312 gimple
313 gimple_build_call (tree fn, unsigned nargs, ...)
(gdb) list -
294
295 gimple
296 gimple_build_call_vec (tree fn, VEC(tree, heap) *args)
297 {
298 unsigned i;
299 unsigned nargs = VEC_length (tree, args);
300 gimple call = gimple_build_call_1 (fn, nargs);
301
302 for (i = 0; i < nargs; i++)
303 gimple_call_set_arg (call, i, VEC_index (tree, args, i));
(gdb) up
#1 0x1081d2ec in vect_recog_pow_pattern (last_stmt=<value optimized out>,
type_in=0xffdeec70, type_out=<value optimized out>) at
/home/meissner/fsf-src/trunk/gcc/tree-vect-patterns.c:521
521 gimple stmt = gimple_build_call (newfn, 1, base);
(gdb) print newfn
$2 = (tree) 0x0
(gdb) list
516 {
517 tree newfn = mathfn_built_in (TREE_TYPE (base), BUILT_IN_SQRT);
518 *type_in = get_vectype_for_scalar_type (TREE_TYPE (base));
519 if (*type_in)
520 {
521 gimple stmt = gimple_build_call (newfn, 1, base);
522 if (vectorizable_function (stmt, *type_in, *type_in)
523 != NULL_TREE)
524 {
525 var = vect_recog_temp_ssa_var (TREE_TYPE (base), stmt);
(gdb) list -
506
507 var = vect_recog_temp_ssa_var (TREE_TYPE (base), NULL);
508 stmt = gimple_build_assign_with_ops (MULT_EXPR, var, base, base);
509 SSA_NAME_DEF_STMT (var) = stmt;
510 return stmt;
511 }
512
513 /* Catch square root. */
514 if (TREE_CODE (exp) == REAL_CST
515 && REAL_VALUES_EQUAL (TREE_REAL_CST (exp), dconsthalf))
(gdb) list 506
501 && tree_low_cst (exp, 0) == 2)
502 || (TREE_CODE (exp) == REAL_CST
503 && REAL_VALUES_EQUAL (TREE_REAL_CST (exp), dconst2)))
504 {
505 *type_in = TREE_TYPE (base);
506
507 var = vect_recog_temp_ssa_var (TREE_TYPE (base), NULL);
508 stmt = gimple_build_assign_with_ops (MULT_EXPR, var, base, base);
509 SSA_NAME_DEF_STMT (var) = stmt;
510 return stmt;
(gdb)
511 }
512
513 /* Catch square root. */
514 if (TREE_CODE (exp) == REAL_CST
515 && REAL_VALUES_EQUAL (TREE_REAL_CST (exp), dconsthalf))
516 {
517 tree newfn = mathfn_built_in (TREE_TYPE (base), BUILT_IN_SQRT);
518 *type_in = get_vectype_for_scalar_type (TREE_TYPE (base));
519 if (*type_in)
520 {
As you can see, the mathfn_built_in is returning NULL, but the code assumes it
is non-null. I will upload a reduced test case as an attachment.
--
Summary: Powerpc spe segfaults in vectorizing powf (a[i], 0.5f)
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: meissner at gcc dot gnu dot org
GCC build triplet: powerpc64-unknown-linux-gnu
GCC host triplet: powerpc64-unknown-linux-gnu
GCC target triplet: powerpc-spe-eabi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40348