Re: [PATCH] Do not mark pseudo-copies decomposable during first lower-subreg pass

2013-08-22 Thread Jay Foad
On 26 September 2012 13:11, Ulrich Weigand  wrote:
> ChangeLog:
>
> * lower-subreg.c (enum classify_move_insn): Rename
> SIMPLE_PSEUDO_REG_MOVE to DECOMPOSABLE_SIMPLE_MOVE.
> (find_decomposable_subregs): Update.
> (decompose_multiword_subregs): Add DECOMPOSE_COPIES parameter.
> Only mark pseudo-to-pseudo copies as DECOMPOSABLE_SIMPLE_MOVE
> if that parameter is true.
> (rest_of_handle_lower_subreg): Call decompose_multiword_subregs
> with DECOMPOSE_COPIES false.
> (rest_of_handle_lower_subreg2): Call decompose_multiword_subregs
> with DECOMPOSE_COPIES true.

This patch seems to have caused a slight regression in ARM register allocation:

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

Jay.


Fwd: libcpp/C FE source range patch committed (r230331).

2015-11-24 Thread Jay Foad
(Resending as plain text. Sorry for the HTML!)

On 14 November 2015 at 14:50, David Edelsohn  wrote:
>
> This patch causes numerous new testsuite failure on AIX caused by the
> compiler crashing during compilation, e.g.

r230331 also seems to be causing this on x86_64-pc-linux-gnu:

$ cat x.c
#define P(b) b&&4
int a[]=0;
int f() { X||P(d); }
$ ~/gcc/build/gcc/cc1 -quiet -Wall x.c
[...]
x.c:3:1: internal compiler error: in contains_point, at
diagnostic-show-locus.c:335
 int f() { X||P(d); }
 ^~~

0x1268fc9 contains_point
/home/jay/svn/gcc/trunk/gcc/diagnostic-show-locus.c:335
0x1268fc9 get_state_at_point
/home/jay/svn/gcc/trunk/gcc/diagnostic-show-locus.c:612
0x12696e2 print_source_line
/home/jay/svn/gcc/trunk/gcc/diagnostic-show-locus.c:533
0x12696e2 diagnostic_show_locus(diagnostic_context*, diagnostic_info const*)
/home/jay/svn/gcc/trunk/gcc/diagnostic-show-locus.c:710
0x69b210 c_diagnostic_finalizer
/home/jay/svn/gcc/trunk/gcc/c-family/c-opts.c:167
0x1267220 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
/home/jay/svn/gcc/trunk/gcc/diagnostic.c:800
0x1267b07 warning_at(unsigned int, int, char const*, ...)
/home/jay/svn/gcc/trunk/gcc/diagnostic.c:1029
0x607e58 parser_build_binary_op(unsigned int, tree_code, c_expr, c_expr)
/home/jay/svn/gcc/trunk/gcc/c/c-typeck.c:3514
0x61855a c_parser_binary_expression
/home/jay/svn/gcc/trunk/gcc/c/c-parser.c:6539
0x618a18 c_parser_conditional_expression
/home/jay/svn/gcc/trunk/gcc/c/c-parser.c:6182
0x619100 c_parser_expr_no_commas
/home/jay/svn/gcc/trunk/gcc/c/c-parser.c:6099
0x6198d2 c_parser_expression
/home/jay/svn/gcc/trunk/gcc/c/c-parser.c:8230
0x61a3a9 c_parser_expression_conv
/home/jay/svn/gcc/trunk/gcc/c/c-parser.c:8263
0x633431 c_parser_statement_after_labels
/home/jay/svn/gcc/trunk/gcc/c/c-parser.c:5172
0x635065 c_parser_compound_statement_nostart
/home/jay/svn/gcc/trunk/gcc/c/c-parser.c:4757
0x6358ae c_parser_compound_statement
/home/jay/svn/gcc/trunk/gcc/c/c-parser.c:4594
0x6314e3 c_parser_declaration_or_fndef
/home/jay/svn/gcc/trunk/gcc/c/c-parser.c:2015
0x63d31d c_parser_external_declaration
/home/jay/svn/gcc/trunk/gcc/c/c-parser.c:1459
0x63dbe9 c_parser_translation_unit
/home/jay/svn/gcc/trunk/gcc/c/c-parser.c:1346
0x63dbe9 c_parse_file()
/home/jay/svn/gcc/trunk/gcc/c/c-parser.c:17622
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

Jay.


Re: Fwd: libcpp/C FE source range patch committed (r230331).

2015-11-24 Thread Jay Foad
On 24 November 2015 at 11:34, Marek Polacek  wrote:
> On Tue, Nov 24, 2015 at 11:24:38AM +0000, Jay Foad wrote:
>> r230331 also seems to be causing this on x86_64-pc-linux-gnu:
>>
>> $ cat x.c
>> #define P(b) b&&4
>> int a[]=0;
>> int f() { X||P(d); }
>> $ ~/gcc/build/gcc/cc1 -quiet -Wall x.c
>> [...]
>> x.c:3:1: internal compiler error: in contains_point, at
>> diagnostic-show-locus.c:335
>>  int f() { X||P(d); }
>
> Could you please open a PR?

I see now that it's already reported as PR c/68473.

Jay.

Jay.


Re: [RFC][ARM] TARGET_ATOMIC_ASSIGN_EXPAND_FENV hook

2014-06-23 Thread Jay Foad
On 2 May 2014 10:04, Kugan  wrote:
> Thanks for spotting it. Here is the updated patch that changes it to
> ARM_FE_*.

> +2014-05-02  Kugan Vivekanandarajah  
> +
> +   * config/arm/arm.c (TARGET_ATOMIC_ASSIGN_EXPAND_FENV): New define.
> +   (arm_builtins) : Add ARM_BUILTIN_GET_FPSCR and ARM_BUILTIN_SET_FPSCR.
> +   (bdesc_2arg) : Add description for builtins __builtins_arm_set_fpscr
> +   and __builtins_arm_get_fpscr.

s/__builtins/__builtin/g

> +   (arm_init_builtins) : Initialize builtins __builtins_arm_set_fpscr and
> +   __builtins_arm_get_fpscr.

s/__builtins/__builtin/g

This doesn't match the code, which initializes builtins "...ldfscr"
and "...stfscr" (with no "p" in "fscr").

> +   (arm_expand_builtin) : Expand builtins __builtins_arm_set_fpscr and
> +   __builtins_arm_ldfpscr.

s/__builtins/__builtin/g

Did you mean "and __builtin_arm_get_fpscr"?

> +#define FP_BUILTIN(L, U) \
> +  {0, CODE_FOR_##L, "__builtin_arm_"#L, ARM_BUILTIN_##U, \
> +   UNKNOWN, 0},
> +
> +  FP_BUILTIN (set_fpscr, GET_FPSCR)
> +  FP_BUILTIN (get_fpscr, SET_FPSCR)
> +#undef FP_BUILTIN

This looks like a typo: you have mapped set->GET and get->SET.

Jay.


Re: [RFC 0/6] Flags outputs for asms

2015-05-08 Thread Jay Foad
On 8 May 2015 at 16:23, Richard Henderson  wrote:
> Yes, the i386 backend has not implemented conditional sibcalls.

See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60159

Jay.


Re: [PATCH] Make IPA-CP propagate alignment information of pointers

2014-12-03 Thread Jay Foad
> Index: src/gcc/ipa-cp.c
> ===
> --- src.orig/gcc/ipa-cp.c
> +++ src/gcc/ipa-cp.c
> @@ -262,6 +262,9 @@ public:
>ipcp_lattice ctxlat;
>/* Lattices describing aggregate parts.  */
>ipcp_agg_lattice *aggs;
> +  /* Alignment information.  Very basic one value lattice where !known means
> + TOP and zero alignment bottom.  */
> +  ipa_alignment alignment;
>/* Number of aggregate lattices */
>int aggs_count;
>/* True if aggregate data were passed by reference (as opposed to by
> @@ -444,6 +447,13 @@ print_all_lattices (FILE * f, bool dump_
>   plats->itself.print (f, dump_sources, dump_benefits);
>   fprintf (f, " ctxs: ");
>   plats->ctxlat.print (f, dump_sources, dump_benefits);
> + if (plats->alignment.known && plats->alignment.align > 0)
> +   fprintf (f, " Alignment %u, misaglignment %u\n",

"misalignment"

> +plats->alignment.align, plats->alignment.misalign);
> + else if (plats->alignment.known)
> +   fprintf (f, " Alignment unusable\n");
> + else
> +   fprintf (f, " Alignment unknown\n");
>   if (plats->virt_call)
> fprintf (f, "virt_call flag set\n");
>
> @@ -761,6 +771,27 @@ set_agg_lats_contain_variable (struct ip
>return ret;
>  }
>
> +/* Return true if alignemnt informatin in PLATS is known to be unusable.  */

"alignment", "information"

> +
> +static inline bool
> +alignment_bottom_p (ipcp_param_lattices *plats)
> +{
> +  return plats->alignment.known && (plats->alignment.align == 0);
> +}
> +
> +/* Set alignment information in PLATS to unusable.  Return true if it
> +   previously was usable or unknown.  */
> +
> +static inline bool
> +set_alignment_to_bottom (ipcp_param_lattices *plats)
> +{
> +  if (alignment_bottom_p (plats))
> +return false;
> +  plats->alignment.known = true;
> +  plats->alignment.align = 0;
> +  return true;
> +}
> +
>  /* Mark bot aggregate and scalar lattices as containing an unknown variable,
> return true is any of them has not been marked as such so far.  */
>
> @@ -771,6 +802,7 @@ set_all_contains_variable (struct ipcp_p
>ret = plats->itself.set_contains_variable ();
>ret |= plats->ctxlat.set_contains_variable ();
>ret |= set_agg_lats_contain_variable (plats);
> +  ret |= set_alignment_to_bottom (plats);
>return ret;
>  }
>
> @@ -807,6 +839,7 @@ initialize_node_lattices (struct cgraph_
>   plats->itself.set_to_bottom ();
>   plats->ctxlat.set_to_bottom ();
>   set_agg_lats_to_bottom (plats);
> + set_alignment_to_bottom (plats);
> }
>   else
> set_all_contains_variable (plats);
> @@ -1369,6 +1402,77 @@ propagate_context_accross_jump_function
>return ret;
>  }
>
> +/* Propagate alignments accross jump function JFUNC that is associated with

"across"

> +   edge CS and update DEST_LAT accordingly.  */
> +
> +static bool
> +propagate_alignment_accross_jump_function (struct cgraph_edge *cs,
> +  struct ipa_jump_func *jfunc,
> +  struct ipcp_param_lattices 
> *dest_lat)
> +{
> +  if (alignment_bottom_p (dest_lat))
> +return false;
> +
> +  ipa_alignment cur;
> +  cur.known = false;
> +  if (jfunc->alignment.known)
> +cur = jfunc->alignment;
> +  else if (jfunc->type == IPA_JF_PASS_THROUGH
> +  || jfunc->type == IPA_JF_ANCESTOR)
> +{
> +  struct ipa_node_params *caller_info = IPA_NODE_REF (cs->caller);
> +  struct ipcp_param_lattices *src_lats;
> +  HOST_WIDE_INT offset = 0;
> +  int src_idx;
> +
> +  if (jfunc->type == IPA_JF_PASS_THROUGH)
> +   {
> + enum tree_code op = ipa_get_jf_pass_through_operation (jfunc);
> + if (op != NOP_EXPR)
> +   {
> + if (op != POINTER_PLUS_EXPR
> + && op != PLUS_EXPR
> + && op != MINUS_EXPR)
> +   goto prop_fail;
> + tree operand = ipa_get_jf_pass_through_operand (jfunc);
> + if (!tree_fits_shwi_p (operand))
> +   goto prop_fail;
> + offset = tree_to_shwi (operand);
> +   }
> + src_idx = ipa_get_jf_pass_through_formal_id (jfunc);
> +   }
> +  else
> +   {
> + src_idx = ipa_get_jf_ancestor_formal_id (jfunc);
> + offset = ipa_get_jf_ancestor_offset (jfunc);
> +   }
> +
> +  src_lats = ipa_get_parm_lattices (caller_info, src_idx);
> +  if (!src_lats->alignment.known
> + || alignment_bottom_p (src_lats))
> +   goto prop_fail;
> +
> +  cur = src_lats->alignment;
> +  cur.misalign = (cur.misalign + offset) % cur.align;
> +}
> +
> +  if (cur.known)
> +{
> +  if (!dest_lat->alignment.known)
> +   {
> + dest_lat->alignment = cur;
> + return true;
>

Re: [PATCH] Make IPA-CP propagate alignment information of pointers

2014-12-05 Thread Jay Foad
On 3 December 2014 at 14:36, Martin Jambor  wrote:
> On Wed, Dec 03, 2014 at 10:53:54AM +0000, Jay Foad wrote:
>> > Index: src/gcc/ipa-prop.h
>> > ===
>> > --- src.orig/gcc/ipa-prop.h
>> > +++ src/gcc/ipa-prop.h
>> > @@ -144,6 +144,17 @@ struct GTY(()) ipa_agg_jump_function
>> >
>> >  typedef struct ipa_agg_jump_function *ipa_agg_jump_function_p;
>> >
>> > +/* Info about poiner alignments. */
>>
>> "pointer"
>>
>> > +struct GTY(()) ipa_alignment
>> > +{
>> > +  /* The data fields below are valid only if known is true.  */
>> > +  bool known;
>>
>> Just curious: why is the "known" flag necessary? The comments for
>> ptr_info_def say that align=0 means unknown.
>
> It is necessary.  In IPA-CP, when know is false, this means the
> lattice is in TOP state (i.e. once we learn something about the
> parameter, let's overwrite this), whereas when it is true and
> alignment is 0, it means it is in BOTTOM state (i.e. we know we cannot
> rely on this and never will be able to).

Can't you use align=1, misalign=0 for TOP ? This means that we don't
know anything useful about the pointer yet, just that it's a multiple
of 1 (which is trivially true for all pointers, isn't it?).

When you have vectors of these struct they will pack MUCH more nicely
without the "bool known" field.

Thanks,
Jay.


Re: [PATCH][RFC] Move TREE_VEC length and SSA_NAME version into tree_base

2012-08-21 Thread Jay Foad
On 21 August 2012 10:58, Richard Guenther  wrote:
> Index: trunk/gcc/tree.h
> ===
> *** trunk.orig/gcc/tree.h   2012-08-20 12:47:47.0 +0200
> --- trunk/gcc/tree.h2012-08-21 10:32:47.717394657 +0200
> *** enum omp_clause_code
> *** 417,423 
>  so all nodes have these fields.
>
>  See the accessor macros, defined below, for documentation of the
> !fields.  */
>
>   struct GTY(()) tree_base {
> ENUM_BITFIELD(tree_code) code : 16;
> --- 417,424 
>  so all nodes have these fields.
>
>  See the accessor macros, defined below, for documentation of the
> !fields, and the table below which connects the fileds and the
> !accessor macros.  */

Typo "fileds".

Jay.


Re: VxWorks Patches Back from the Dead!

2012-08-23 Thread Jay Foad
On 23 August 2012 09:24, Paolo Bonzini  wrote:
> Il 23/08/2012 04:27, rbmj ha scritto:
>> + c_fix_arg   = "%0\n"
>> + "#define ioctl(fd, func, arg) ((ioctl)((fd), (func), 
>> ((int)(arg\n";
>
> This can be simply
>
> #define ioctl(fd, func, arg) ioctl(fd, func, (int)arg)

"(int)(arg)", surely.

Jay.


Re: Turn check macros into functions. (issue6188088)

2012-05-18 Thread Jay Foad
On 18 May 2012 12:46, Diego Novillo  wrote:
> On 12-05-18 06:14 , Richard Guenther wrote:
>
>> As you retain the macros anyway you can simply not return anything
>> from the C++ checking functions define to a stmt expression
>> ({ check_in_cxx (t); t; })
>
>
> Sure, but that takes us back to the original gdb issue: it does not
> understand statement expressions.

What's wrong with:

(check_in_cxx(t), t)

?

Jay.


Re: [PATCH] Extend VRP BIT_IOR_EXPR to handle sign-bit

2011-08-09 Thread Jay Foad
On 9 August 2011 13:23, Richard Guenther  wrote:
> 2011-08-08  Richard Guenther  
>
>        * tree-vrp.c (zero_nonzero_bits_from_vr): Also return precise
>        information for with only negative values.

"for *ranges* with" ?

Jay.


Re: [PATCH] Support for known unknown alignment

2012-04-20 Thread Jay Foad
On 20 April 2012 16:54, Martin Jambor  wrote:
> two days ago I talked to Richi on IRC about the functions to determine
> the expected alignment of objects and pointers we have and he
> suggested that get_object_alignment_1 and get_pointer_alignment_1
> should return whether the alignment is actually known

Can you explain how returning "unknown" is different from returning
some minimal known alignment? Comments like:

> ! /* Compute values M and N such that M divides (address of EXP - N) and
> !    such that N < M.  Store N in *BITPOSP and return M.

suggest that M=1, N=0 is always a valid conservative thing to return.

If there is a difference, the comment should explain what it means.

Thanks,
Jay.


Re: [PATCH] Support for known unknown alignment

2012-04-23 Thread Jay Foad
On 23 April 2012 14:30, Richard Guenther  wrote:
> Well, CCP simply tracks known-bits and derives the alignment
> value from that.  If tem & -tem computes as zero that means
> val->mask.low is all zeros.

Doesn't that mean that all bits are known? So you could set:

  pi->align = 1 << 32; // or some suitably large power of two
  pi->misalign = val->value;

Jay.


Re: [PATCH][RFC][1/2] Bitfield lowering, add BIT_FIELD_EXPR

2011-06-16 Thread Jay Foad
> BIT_FIELD_EXPR  is equivalent to computing
> a & ~((1 << C1 - 1) << C2) | ((b << C2) & (1 << C1 = 1)),

a & ~(((1 << C1) - 1) << C2) | ((b & ((1 << C1) - 1)) << C2)

?

Jay.

 thus
> inserting b of width C1 at the bitfield position C2 in a, returning
> the new value.  This allows translating
>  BIT_FIELD_REF  = b;
> to
>  a = BIT_FIELD_EXPR ;
> which avoids partial definitions of a (thus, BIT_FIELD_EXPR is
> similar to COMPLEX_EXPR).  BIT_FIELD_EXPR is supposed to work
> on registers only.
>
> Comments welcome, esp. on how to avoid introducing quaternary
> RHS on gimple stmts (or using a GIMPLE_SINGLE_RHS as the patch does).
>
> Folders/combiners are missing to handle some of the easy
> BIT_FIELD_REF / BIT_FIELD_EXPR cases, as well as eventually
> re-writing shift/mask operations to BIT_FIELD_REF/EXPR.
>
> Richard.
>
> 2011-06-16  Richard Guenther  
>
>        * expr.c (expand_expr_real_1): Handle BIT_FIELD_EXPR.
>        * fold-const.c (operand_equal_p): Likewise.
>        (build_bit_mask): New function.
>        (fold_quaternary_loc): Likewise.
>        (fold): Call it.
>        (fold_build4_stat_loc): New function.
>        * gimplify.c (gimplify_expr): Handle BIT_FIELD_EXPR.
>        * tree-inline.c (estimate_operator_cost): Likewise.
>        * tree-pretty-print.c (dump_generic_node): Likewise.
>        * tree-ssa-operands.c (get_expr_operands): Likewise.
>        * tree.def (BIT_FIELD_EXPR): New tree code.
>        * tree.h (build_bit_mask): Declare.
>        (fold_quaternary): Define.
>        (fold_quaternary_loc): Declare.
>        (fold_build4): Define.
>        (fold_build4_loc): Likewise.
>        (fold_build4_stat_loc): Declare.
>        * gimple.c (gimple_rhs_class_table): Handle BIT_FIELD_EXPR.
>
> Index: trunk/gcc/expr.c
> ===
> *** trunk.orig/gcc/expr.c       2011-06-15 13:27:40.0 +0200
> --- trunk/gcc/expr.c    2011-06-15 15:08:41.0 +0200
> *** expand_expr_real_1 (tree exp, rtx target
> *** 8680,8685 
> --- 8680,8708 
>
>        return expand_constructor (exp, target, modifier, false);
>
> +     case BIT_FIELD_EXPR:
> +       {
> +         unsigned bitpos = (unsigned) TREE_INT_CST_LOW (TREE_OPERAND (exp, 
> 3));
> +         unsigned bitsize = (unsigned) TREE_INT_CST_LOW (TREE_OPERAND (exp, 
> 2));
> +         tree bits, mask;
> +         if (BYTES_BIG_ENDIAN)
> +           bitpos = TYPE_PRECISION (type) - bitsize - bitpos;
> +         /* build a mask to mask/clear the bits in the word.  */
> +         mask = build_bit_mask (type, bitsize, bitpos);
> +         /* extend the bits to the word type, shift them to the right
> +            place and mask the bits.  */
> +         bits = fold_convert (type, TREE_OPERAND (exp, 1));
> +         bits = fold_build2 (BIT_AND_EXPR, type,
> +                             fold_build2 (LSHIFT_EXPR, type,
> +                                          bits, size_int (bitpos)), mask);
> +         /* switch to clear mask and do the composition.  */
> +         mask = fold_build1 (BIT_NOT_EXPR, type, mask);
> +         return expand_normal (fold_build2 (BIT_IOR_EXPR, type,
> +                               fold_build2 (BIT_AND_EXPR, type,
> +                                            TREE_OPERAND (exp, 0), mask),
> +                               bits));
> +       }
> +
>      case TARGET_MEM_REF:
>        {
>        addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (exp));
> Index: trunk/gcc/fold-const.c
> ===
> *** trunk.orig/gcc/fold-const.c 2011-06-15 14:51:31.0 +0200
> --- trunk/gcc/fold-const.c      2011-06-15 15:33:04.0 +0200
> *** operand_equal_p (const_tree arg0, const_
> *** 2667,2672 
> --- 2667,2675 
>        case DOT_PROD_EXPR:
>          return OP_SAME (0) && OP_SAME (1) && OP_SAME (2);
>
> +       case BIT_FIELD_EXPR:
> +         return OP_SAME (0) && OP_SAME (1) && OP_SAME (2) && OP_SAME (3);
> +
>        default:
>          return 0;
>        }
> *** contains_label_p (tree st)
> *** 13230,13235 
> --- 13233,13251 
>     (walk_tree_without_duplicates (&st, contains_label_1 , NULL) != 
> NULL_TREE);
>  }
>
> + /* Builds and returns a mask of integral type TYPE for masking out
> +    BITSIZE bits at bit position BITPOS in a word of type TYPE.
> +    The mask has the bits set from bit BITPOS to BITPOS + BITSIZE - 1.  */
> +
> + tree
> + build_bit_mask (tree type, unsigned int bitsize, unsigned int bitpos)
> + {
> +   tree mask = double_int_to_tree (type, double_int_mask (bitsize));
> +   mask = const_binop (LSHIFT_EXPR, mask, size_int (bitpos));
> +
> +   return mask;
> + }
> +
>  /* Fold a ternary expression of code CODE and type TYPE with operands
>     OP0, OP1, and OP2.  Return the folded expression if folding is
>     successful.  Otherwise, return NULL_TREE.  */
> *** fold_ternary_loc (location_t loc, enum t
> *** 13

Re: RFA: Fix bogus mode in choose_reload_regs

2011-07-07 Thread Jay Foad
On 7 July 2011 09:09, Richard Sandiford  wrote:
> gcc/
>        * reload1.c (choose_reload_regs): Use mode sizes to check whether
>        an old relaod register completely defines the required value.

s/relaod/reload/

Jay.


Re: [PATCH][1/n][C] Do not sign-extend sizetypes

2011-04-11 Thread Jay Foad
On 11 April 2011 15:25, Richard Guenther  wrote:
> !   set_min_and_max_values_for_integral_type (t, precision,
> !                                           /*is_unsinged=*/true);

s/ng/gn/

Jay.