On 19 October 2015 at 15:54, Richard Biener <rguent...@suse.de> wrote: > > Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. >
Hi Richard, This patch caused arm and aarch64 builds of newlib to cause ICEs: In file included from /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/newlib/newlib/libc/include/stdlib.h:11:0, from /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/newlib/newlib/libc/time/mktm_r.c:13: /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/newlib/newlib/libc/time/mktm_r.c: In function '_mktm_r': /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/newlib/newlib/libc/time/mktm_r.c:28:9: internal compiler error: Segmentation fault _DEFUN (_mktm_r, (tim_p, res, is_gmtime), 0xa90205 crash_signal /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/toplev.c:353 0x7b3b0c tree_class_check /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree.h:3055 0x7b3b0c tree_single_nonnegative_warnv_p(tree_node*, bool*, int) /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/fold-const.c:13025 0x814053 gimple_phi_nonnegative_warnv_p /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimple-fold.c:6239 0x814053 gimple_stmt_nonnegative_warnv_p(gimple*, bool*, int) /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimple-fold.c:6264 0x7b5c94 tree_expr_nonnegative_p(tree_node*) /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/fold-const.c:13325 0xe2f657 gimple_simplify_108 /tmp/884316_1.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-arm-none-eabi/gcc1/gcc/gimple-match.c:5116 0xe3060d gimple_simplify_TRUNC_MOD_EXPR /tmp/884316_1.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-arm-none-eabi/gcc1/gcc/gimple-match.c:24762 0xe0809b gimple_simplify /tmp/884316_1.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-arm-none-eabi/gcc1/gcc/gimple-match.c:34389 0xe08c2b gimple_resimplify2(gimple**, code_helper*, tree_node*, tree_node**, tree_node* (*)(tree_node*)) /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimple-match-head.c:193 0xe17600 gimple_simplify(gimple*, code_helper*, tree_node**, gimple**, tree_node* (*)(tree_node*), tree_node* (*)(tree_node*)) /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimple-match-head.c:762 0x81c694 fold_stmt_1 /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimple-fold.c:3605 0xad0f6c replace_uses_by(tree_node*, tree_node*) /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree-cfg.c:1835 0xad1a2f gimple_merge_blocks /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree-cfg.c:1921 0x67d325 merge_blocks(basic_block_def*, basic_block_def*) /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cfghooks.c:776 0xae06da cleanup_tree_cfg_bb /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree-cfgcleanup.c:654 0xae1118 cleanup_tree_cfg_1 /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree-cfgcleanup.c:686 0xae1118 cleanup_tree_cfg_noloop /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree-cfgcleanup.c:738 0xae1118 cleanup_tree_cfg() /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree-cfgcleanup.c:793 0x9c5c94 execute_function_todo /tmp/884316_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1920 Please submit a full bug report, This happens for instance with GCC configured --target arm-none-eabi --with-cpu cortex-a9 You can download logs of a failed build from http://people.linaro.org/~christophe.lyon/cross-validation/gcc-build/trunk/228970/build.html Sorry, I'm out of office for one week, I can't produce further details. Christophe > Richard. > > 2015-10-19 Richard Biener <rguent...@suse.de> > > * gimple-fold.c (gimple_phi_nonnegative_warnv_p): New function. > (gimple_stmt_nonnegative_warnv_p): Use it. > * match.pd (CPROJ): New operator list. > (cproj (complex ...)): Move simplifications from ... > * builtins.c (fold_builtin_cproj): ... here. > > * gcc.dg/torture/builtin-cproj-1.c: Skip for -O0. > > Index: gcc/gimple-fold.c > =================================================================== > --- gcc/gimple-fold.c (revision 228877) > +++ gcc/gimple-fold.c (working copy) > @@ -6224,6 +6224,24 @@ gimple_call_nonnegative_warnv_p (gimple > strict_overflow_p, depth); > } > > +/* Return true if return value of call STMT is known to be non-negative. > + If the return value is based on the assumption that signed overflow is > + undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't change > + *STRICT_OVERFLOW_P. DEPTH is the current nesting depth of the query. */ > + > +static bool > +gimple_phi_nonnegative_warnv_p (gimple *stmt, bool *strict_overflow_p, > + int depth) > +{ > + for (unsigned i = 0; i < gimple_phi_num_args (stmt); ++i) > + { > + tree arg = gimple_phi_arg_def (stmt, i); > + if (!tree_single_nonnegative_warnv_p (arg, strict_overflow_p, depth + > 1)) > + return false; > + } > + return true; > +} > + > /* Return true if STMT is known to compute a non-negative value. > If the return value is based on the assumption that signed overflow is > undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't change > @@ -6241,6 +6259,9 @@ gimple_stmt_nonnegative_warnv_p (gimple > case GIMPLE_CALL: > return gimple_call_nonnegative_warnv_p (stmt, strict_overflow_p, > depth); > + case GIMPLE_PHI: > + return gimple_phi_nonnegative_warnv_p (stmt, strict_overflow_p, > + depth); > default: > return false; > } > Index: gcc/match.pd > =================================================================== > --- gcc/match.pd (revision 228877) > +++ gcc/match.pd (working copy) > @@ -61,6 +61,7 @@ (define_operator_list COS BUILT_IN_COSF > (define_operator_list TAN BUILT_IN_TANF BUILT_IN_TAN BUILT_IN_TANL) > (define_operator_list COSH BUILT_IN_COSHF BUILT_IN_COSH BUILT_IN_COSHL) > (define_operator_list CEXPI BUILT_IN_CEXPIF BUILT_IN_CEXPI BUILT_IN_CEXPIL) > +(define_operator_list CPROJ BUILT_IN_CPROJF BUILT_IN_CPROJ BUILT_IN_CPROJL) > > /* Simplifications of operations with one constant operand and > simplifications to constants or single values. */ > @@ -2361,6 +2362,32 @@ (define_operator_list CEXPI BUILT_IN_CEX > (cbrts (pows tree_expr_nonnegative_p@0 @1)) > (pows @0 (mult @1 { build_real_truncate (type, dconst_third ()); }))))) > > +/* If the real part is inf and the imag part is known to be > + nonnegative, return (inf + 0i). */ > +(simplify > + (CPROJ (complex REAL_CST@0 tree_expr_nonnegative_p@1)) > + (if (real_isinf (TREE_REAL_CST_PTR (@0))) > + (with > + { > + REAL_VALUE_TYPE rinf; > + real_inf (&rinf); > + } > + { build_complex (type, build_real (TREE_TYPE (type), rinf), > + build_zero_cst (TREE_TYPE (type))); }))) > +/* If the imag part is inf, return (inf+I*copysign(0,imag)). */ > +(simplify > + (CPROJ (complex @0 REAL_CST@1)) > + (if (real_isinf (TREE_REAL_CST_PTR (@1))) > + (with > + { > + REAL_VALUE_TYPE rinf, rzero = dconst0; > + real_inf (&rinf); > + rzero.sign = TREE_REAL_CST_PTR (@1)->sign; > + } > + { build_complex (type, build_real (TREE_TYPE (type), rinf), > + build_real (TREE_TYPE (type), rzero)); }))) > + > + > /* Narrowing of arithmetic and logical operations. > > These are conceptually similar to the transformations performed for > Index: gcc/builtins.c > =================================================================== > --- gcc/builtins.c (revision 228877) > +++ gcc/builtins.c (working copy) > @@ -7657,33 +7657,6 @@ fold_builtin_cproj (location_t loc, tree > else > return arg; > } > - else if (TREE_CODE (arg) == COMPLEX_EXPR) > - { > - tree real = TREE_OPERAND (arg, 0); > - tree imag = TREE_OPERAND (arg, 1); > - > - STRIP_NOPS (real); > - STRIP_NOPS (imag); > - > - /* If the real part is inf and the imag part is known to be > - nonnegative, return (inf + 0i). Remember side-effects are > - possible in the imag part. */ > - if (TREE_CODE (real) == REAL_CST > - && real_isinf (TREE_REAL_CST_PTR (real)) > - && tree_expr_nonnegative_p (imag)) > - return omit_one_operand_loc (loc, type, > - build_complex_cproj (type, false), > - arg); > - > - /* If the imag part is inf, return (inf+I*copysign(0,imag)). > - Remember side-effects are possible in the real part. */ > - if (TREE_CODE (imag) == REAL_CST > - && real_isinf (TREE_REAL_CST_PTR (imag))) > - return > - omit_one_operand_loc (loc, type, > - build_complex_cproj (type, TREE_REAL_CST_PTR > - (imag)->sign), arg); > - } > > return NULL_TREE; > } > Index: gcc/testsuite/gcc.dg/torture/builtin-cproj-1.c > =================================================================== > --- gcc/testsuite/gcc.dg/torture/builtin-cproj-1.c (revision 228877) > +++ gcc/testsuite/gcc.dg/torture/builtin-cproj-1.c (working copy) > @@ -6,6 +6,7 @@ > Origin: Kaveh R. Ghazi, April 9, 2010. */ > > /* { dg-do link } */ > +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ > /* { dg-add-options ieee } */ > > /* All references to link_error should go away at compile-time. The