Re: Use predicates for RTL objects

2019-08-05 Thread Arvind Sankar
On Mon, Aug 05, 2019 at 12:48:46PM -0500, Segher Boessenkool wrote:
> Hi Arvind,
> 
> First: do you have a copyright assignment?  See
>   https://gcc.gnu.org/contribute.html
> for instructions.

Nope, is this really substantial enough to warrant one?

> 
> This is easier to review, and even to commit as obvious, if you did a
> patch per macro, certainly for the new macros; and, put the script in
> contrib/, and then say with every patch that is just the output of the
> script that that is the case.

Ok, I can split it up that way.

> 
> Some (mostly changelog) comments:
> 
> On Mon, Aug 05, 2019 at 01:09:10PM -0400, Arvind Sankar wrote:
> > * gcc/alias.c, gcc/asan.c, gcc/bb-reorder.c, gcc/bt-load.c: Use 
> > predicate macros for rtx_code comparisons.
> 
> Many of your changelog lines are much too long.  Don't use more than 80
> columns (including the leading tab, which is 8 columns).
> 
> Please mention the exact macros you now use, and/or the actual rtx codes.
That'll be easier once its split up by macro. I'll combine the backend +
target code into one patch per macro.
> 
> Filenames are relative to the directory containing the changelog file
> itself, so you shouldn't have the gcc/ in those filenames.
> 
> > * gcc/config/microblaze/predicates.md, 
> 
> There shouldn't be trailing spaces.
> 
> > * gcc/config/rx/constraints.md, gcc/config/rx/rx.c, gcc/config/rx/rx.h: 
> > Likewise.
> 
> And you normally have a separate entry for every file.
> 

I tried to make the changelog a bit shorter by combining filenames into
the same line-- should be easier all around to generate that with one entry per 
file.
> > -/* Predicate yielding true iff X is an rtx for a double-int.  */
> > +/* Predicate yielding true iff X is an rtx for a floating point constant.  
> > */
> >  #define CONST_DOUBLE_AS_FLOAT_P(X) \
> >(GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) != VOIDmode)
> 
> Is const_double really only used for floating point these days?
> 
> 
> Segher
Are you asking if the CONST_DOUBLE_AS_INT_P possibility is dead code
now? That's beyond my current level of understanding of the code,
hopefully someone else will chime in.


Re: Use predicates for RTL objects

2019-08-05 Thread Arvind Sankar
On Mon, Aug 05, 2019 at 01:29:26PM -0500, Segher Boessenkool wrote:
> On Mon, Aug 05, 2019 at 02:14:50PM -0400, Arvind Sankar wrote:
> > On Mon, Aug 05, 2019 at 12:48:46PM -0500, Segher Boessenkool wrote:
> > > > -/* Predicate yielding true iff X is an rtx for a double-int.  */
> > > > +/* Predicate yielding true iff X is an rtx for a floating point 
> > > > constant.  */
> > > >  #define CONST_DOUBLE_AS_FLOAT_P(X) \
> > > >(GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) != VOIDmode)
> > > 
> > > Is const_double really only used for floating point these days?
> 
> > Are you asking if the CONST_DOUBLE_AS_INT_P possibility is dead code
> > now? That's beyond my current level of understanding of the code,
> > hopefully someone else will chime in.
> 
> I am asking if the change to this comment is correct.
> 

Ah. The comment was originally copy-pasted from the one for
CONST_DOUBLE_AS_INT_P, and it seemed clearly wrong. The comment for
CONST_DOUBLE_P (which only checks the code and not the machine mode)
says it can either be a double-int or a floating point constant.


[PATCH v2 01/18] Fix CONST_DOUBLE_AS_FLOAT_P comment.

2019-08-05 Thread Arvind Sankar
2019-08-05  Arvind Sankar  

gcc/ChangeLog:

* rtl.h: Fix comment for CONST_DOUBLE_AS_FLOAT_P and move
it together with the other CONST_DOUBLE predicates.

 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/rtl.h b/gcc/rtl.h
index 039ab05f951..28b5a82d651 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -814,6 +814,10 @@ struct GTY(()) rtvec_def {
 #define CONST_DOUBLE_AS_INT_P(X) \
   (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) == VOIDmode)
 
+/* Predicate yielding true iff X is an rtx for a floating point const.  */
+#define CONST_DOUBLE_AS_FLOAT_P(X) \
+  (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) != VOIDmode)
+
 /* Predicate yielding true iff X is an rtx for a integer const.  */
 #if TARGET_SUPPORTS_WIDE_INT
 #define CONST_SCALAR_INT_P(X) \
@@ -823,10 +827,6 @@ struct GTY(()) rtvec_def {
   (CONST_INT_P (X) || CONST_DOUBLE_AS_INT_P (X))
 #endif
 
-/* Predicate yielding true iff X is an rtx for a double-int.  */
-#define CONST_DOUBLE_AS_FLOAT_P(X) \
-  (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) != VOIDmode)
-
 /* Predicate yielding nonzero iff X is a label insn.  */
 #define LABEL_P(X) (GET_CODE (X) == CODE_LABEL)
 
-- 
2.21.0



Re: Use predicates for RTL objects

2019-08-05 Thread Arvind Sankar
Here's the patches split up. The ones that say autogenerated were
generated from the script below.

I haven't included that as a patch yet since not sure about the
copyright/licensing boilerplate to insert in it.

contrib/rtl-pred.sh:

#!/bin/sh

# 
codes="CONST_INT|CONST_WIDE_INT|CONST_FIXED|CONST_DOUBLE|CONST_VECTOR|CONST_STRING|REG|SUBREG|MEM|LABEL_REF|SYMBOL_REF|DEBUG_INSN"

if test $# != 1 -a $# != 2; then
echo "Usage: $0  []" >&2
exit 1
fi

rtx_code="$1"
rtx_pred="$2"

if [ "x${rtx_pred}" == "x" ]; then
rtx_pred=${rtx_code}
fi

find . -path ./testsuite -prune -o -type f -regex '.*\.\(c\|cc\|h\|md\)' \! 
-path ./rtl.h -print | xargs \
perl -pi -e 's/\bGET_CODE[ ]?(\((?:(?>[^()]+)|(?1))*\)) (?|(!)=|==) 
('${rtx_code}')\b/$2'${rtx_pred}'_P $1/g'



[PATCH v2 03/18] Use CONST_INT_P macro.

2019-08-05 Thread Arvind Sankar
2019-08-05  Arvind Sankar  

gcc/ChangeLog:

* combine-stack-adj.c: Convert GET_CODE (..) == CONST_INT
to CONST_INT_P (..).

 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/combine-stack-adj.c b/gcc/combine-stack-adj.c
index 3638a1b10ee..f98a0d54c98 100644
--- a/gcc/combine-stack-adj.c
+++ b/gcc/combine-stack-adj.c
@@ -634,8 +634,7 @@ combine_stack_adjustments_for_block (basic_block bb)
  && GET_CODE (XEXP (XEXP (dest, 0), 1)) == PLUS
  && XEXP (XEXP (XEXP (dest, 0), 1), 0)
 == stack_pointer_rtx
- && GET_CODE (XEXP (XEXP (XEXP (dest, 0), 1), 1))
-== CONST_INT
+ && CONST_INT_P (XEXP (XEXP (XEXP (dest, 0), 1), 1))
  && INTVAL (XEXP (XEXP (XEXP (dest, 0), 1), 1))
 == -last_sp_adjust))
  && XEXP (XEXP (dest, 0), 0) == stack_pointer_rtx
-- 
2.21.0



[PATCH v2 04/18] Use CONST_WIDE_INT_P macro. Autogenerated patch by running ../contrib/rtl-pred.sh CONST_WIDE_INT_P

2019-08-05 Thread Arvind Sankar
2019-08-05  Arvind Sankar  

gcc/ChangeLog:

* config/darwin.c: Convert GET_CODE (..) == CONST_WIDE_INT
to CONST_WIDE_INT_P (..).
* config/s390/s390.c: Likewise.
* rtlanal.c: Likewise.

 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index d38867e4227..6eaccd73a9f 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -1751,19 +1751,19 @@ machopic_select_rtx_section (machine_mode mode, rtx x,
 {
   if (GET_MODE_SIZE (mode) == 8
   && (CONST_INT_P (x)
- || GET_CODE (x) == CONST_WIDE_INT
+ || CONST_WIDE_INT_P (x)
  || GET_CODE (x) == CONST_DOUBLE))
 return darwin_sections[literal8_section];
   else if (GET_MODE_SIZE (mode) == 4
   && (CONST_INT_P (x)
-  || GET_CODE (x) == CONST_WIDE_INT
+  || CONST_WIDE_INT_P (x)
   || GET_CODE (x) == CONST_DOUBLE))
 return darwin_sections[literal4_section];
   else if (HAVE_GAS_LITERAL16
   && TARGET_64BIT
   && GET_MODE_SIZE (mode) == 16
   && (CONST_INT_P (x)
-  || GET_CODE (x) == CONST_WIDE_INT
+  || CONST_WIDE_INT_P (x)
   || GET_CODE (x) == CONST_DOUBLE
   || GET_CODE (x) == CONST_VECTOR))
 return darwin_sections[literal16_section];
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index c863514325a..4c55707367d 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -4187,7 +4187,7 @@ legitimate_reload_constant_p (rtx op)
 return true;
 
   /* Accept double-word operands that can be split.  */
-  if (GET_CODE (op) == CONST_WIDE_INT
+  if (CONST_WIDE_INT_P (op)
   || (CONST_INT_P (op)
  && trunc_int_for_mode (INTVAL (op), word_mode) != INTVAL (op)))
 {
@@ -4418,7 +4418,7 @@ s390_reload_symref_address (rtx reg, rtx mem, rtx 
scratch, bool tomem)
   /* Reload might have pulled a constant out of the literal pool.
  Force it back in.  */
   if (CONST_INT_P (mem) || GET_CODE (mem) == CONST_DOUBLE
-  || GET_CODE (mem) == CONST_WIDE_INT
+  || CONST_WIDE_INT_P (mem)
   || GET_CODE (mem) == CONST_VECTOR
   || GET_CODE (mem) == CONST)
 mem = force_const_mem (GET_MODE (reg), mem);
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index 268a38799d6..7da11b399ba 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -6051,7 +6051,7 @@ split_double (rtx value, rtx *first, rtx *second)
}
}
 }
-  else if (GET_CODE (value) == CONST_WIDE_INT)
+  else if (CONST_WIDE_INT_P (value))
 {
   /* All of this is scary code and needs to be converted to
 properly work with any size integer.  */
-- 
2.21.0



[PATCH v2 08/18] Use CONST_VECTOR_P macro. Autogenerated patch by running ../contrib/rtl-pred.sh CONST_VECTOR

2019-08-05 Thread Arvind Sankar
2019-08-05  Arvind Sankar  

gcc/ChangeLog:

* common.md: Convert GET_CODE (..) == CONST_VECTOR to
CONST_VECTOR_P (..).
* config/aarch64/aarch64.c: Likewise.
* config/alpha/alpha.c: Likewise.
* config/arc/arc.c: Likewise.
* config/arc/simdext.md: Likewise.
* config/arm/arm.c: Likewise.
* config/bfin/bfin.md: Likewise.
* config/darwin.c: Likewise.
* config/gcn/gcn-valu.md: Likewise.
* config/gcn/gcn.c: Likewise.
* config/i386/i386-expand.c: Likewise.
* config/i386/i386.c: Likewise.
* config/i386/predicates.md: Likewise.
* config/i386/sse.md: Likewise.
* config/ia64/ia64.c: Likewise.
* config/mips/mips.c: Likewise.
* config/nds32/nds32-dspext.md: Likewise.
* config/nds32/predicates.md: Likewise.
* config/rs6000/predicates.md: Likewise.
* config/rs6000/rs6000-p8swap.c: Likewise.
* config/rs6000/rs6000.c: Likewise.
* config/s390/s390.c: Likewise.
* config/spu/predicates.md: Likewise.
* config/spu/spu.c: Likewise.
* config/tilegx/tilegx.c: Likewise.
* config/tilepro/tilepro.c: Likewise.
* dwarf2out.c: Likewise.
* emit-rtl.c: Likewise.
* explow.c: Likewise.
* rtlanal.c: Likewise.
* simplify-rtx.c: Likewise.
* varasm.c: Likewise.

 32 files changed, 112 insertions(+), 112 deletions(-)

diff --git a/gcc/common.md b/gcc/common.md
index 42c574029b5..ee93f203bd2 100644
--- a/gcc/common.md
+++ b/gcc/common.md
@@ -80,14 +80,14 @@
 (define_constraint "E"
   "Matches a floating-point constant."
   (ior (match_test "CONST_DOUBLE_AS_FLOAT_P (op)")
-   (match_test "GET_CODE (op) == CONST_VECTOR
+   (match_test "CONST_VECTOR_P (op)
&& GET_MODE_CLASS (GET_MODE (op)) == MODE_VECTOR_FLOAT")))
 
 ;; There is no longer a distinction between "E" and "F".
 (define_constraint "F"
   "Matches a floating-point constant."
   (ior (match_test "CONST_DOUBLE_AS_FLOAT_P (op)")
-   (match_test "GET_CODE (op) == CONST_VECTOR
+   (match_test "CONST_VECTOR_P (op)
&& GET_MODE_CLASS (GET_MODE (op)) == MODE_VECTOR_FLOAT")))
 
 (define_constraint "X"
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 68ad4858c76..9bdbc198dae 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -3429,7 +3429,7 @@ aarch64_expand_mov_immediate (rtx dest, rtx imm,
}
  emit_insn (gen_vec_duplicate (dest, op));
}
-  else if (GET_CODE (imm) == CONST_VECTOR
+  else if (CONST_VECTOR_P (imm)
   && !GET_MODE_NUNITS (GET_MODE (imm)).is_constant ())
aarch64_expand_sve_const_vector (dest, imm);
   else
@@ -7503,7 +7503,7 @@ aarch64_const_vec_all_in_range_p (rtx vec,
  HOST_WIDE_INT minval,
  HOST_WIDE_INT maxval)
 {
-  if (GET_CODE (vec) != CONST_VECTOR
+  if (!CONST_VECTOR_P (vec)
   || GET_MODE_CLASS (GET_MODE (vec)) != MODE_VECTOR_INT)
 return false;
 
@@ -13203,7 +13203,7 @@ aarch64_legitimate_constant_p (machine_mode mode, rtx x)
   /* Support CSE and rematerialization of common constants.  */
   if (CONST_INT_P (x)
   || (CONST_DOUBLE_P (x) && GET_MODE_CLASS (mode) == MODE_FLOAT)
-  || GET_CODE (x) == CONST_VECTOR)
+  || CONST_VECTOR_P (x))
 return true;
 
   /* Do not allow vector struct mode constants for Advanced SIMD.
@@ -14621,7 +14621,7 @@ aarch64_simd_valid_immediate (rtx op, 
simd_immediate_info *info,
   scalar_mode elt_mode = GET_MODE_INNER (mode);
   rtx base, step;
   unsigned int n_elts;
-  if (GET_CODE (op) == CONST_VECTOR
+  if (CONST_VECTOR_P (op)
   && CONST_VECTOR_DUPLICATE_P (op))
 n_elts = CONST_VECTOR_NPATTERNS (op);
   else if ((vec_flags & VEC_SVE_DATA)
@@ -14636,7 +14636,7 @@ aarch64_simd_valid_immediate (rtx op, 
simd_immediate_info *info,
*info = simd_immediate_info (elt_mode, base, step);
   return true;
 }
-  else if (GET_CODE (op) == CONST_VECTOR
+  else if (CONST_VECTOR_P (op)
   && CONST_VECTOR_NUNITS (op).is_constant (&n_elts))
 /* N_ELTS set above.  */;
   else
@@ -15096,7 +15096,7 @@ aarch64_simd_make_constant (rtx vals)
   int n_const = 0;
   int i;
 
-  if (GET_CODE (vals) == CONST_VECTOR)
+  if (CONST_VECTOR_P (vals))
 const_vec = vals;
   else if (GET_CODE (vals) == PARALLEL)
 {
@@ -16548,7 +16548,7 @@ aarch64_expand_sve_vec_perm (rtx target, rtx op0, rtx 
op1, rtx sel)
   rtx sel_reg = force_reg (sel_mode, sel);
 
   /* Check if the sel only references the first values vector.  */
-  if (GET_CODE (sel) == CONST_VECTOR
+  if (CONST_VECTOR_P (sel)
   && aarch64_const_vec_all_in_range_p 

[PATCH v2 07/18] Add CONST_VECTOR_P rtx_code predicate.

2019-08-05 Thread Arvind Sankar
2019-08-05  Arvind Sankar  

gcc/ChangeLog:

* rtl.h: Add a predicate macro for checking CONST_VECTOR.

 1 file changed, 3 insertions(+)

diff --git a/gcc/rtl.h b/gcc/rtl.h
index 28b5a82d651..45e2b85867d 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -818,6 +818,9 @@ struct GTY(()) rtvec_def {
 #define CONST_DOUBLE_AS_FLOAT_P(X) \
   (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) != VOIDmode)
 
+/* Predicate yielding nonzero iff X is an rtx for a vector const.  */
+#define CONST_VECTOR_P(X) (GET_CODE (X) == CONST_VECTOR)
+
 /* Predicate yielding true iff X is an rtx for a integer const.  */
 #if TARGET_SUPPORTS_WIDE_INT
 #define CONST_SCALAR_INT_P(X) \
-- 
2.21.0



[PATCH v2 10/18] Use CONST_STRING_P macro. Autogenerated patch by running ../contrib/rtl-pred.sh CONST_STRING

2019-08-05 Thread Arvind Sankar
2019-08-05  Arvind Sankar  

gcc/ChangeLog:

* config/avr/avr.c: Convert GET_CODE (..) == CONST_STRING to
CONST_STRING_P (..).
* dwarf2out.c: Likewise.
* genattrtab.c: Likewise.
* gensupport.c: Likewise.

 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c
index 760e9371a01..015d36728a3 100644
--- a/gcc/config/avr/avr.c
+++ b/gcc/config/avr/avr.c
@@ -2965,7 +2965,7 @@ avr_print_operand (FILE *file, rtx x, int code)
   REAL_VALUE_TO_TARGET_SINGLE (*CONST_DOUBLE_REAL_VALUE (x), val);
   fprintf (file, "0x%lx", val);
 }
-  else if (GET_CODE (x) == CONST_STRING)
+  else if (CONST_STRING_P (x))
 fputs (XSTR (x, 0), file);
   else if (code == 'j')
 fputs (cond_string (GET_CODE (x)), file);
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index c84885a24bb..7417551b120 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -18421,7 +18421,7 @@ loc_list_from_tree_1 (tree loc, int want_address,
  val &= GET_MODE_MASK (DECL_MODE (loc));
ret = int_loc_descriptor (val);
  }
-   else if (GET_CODE (rtl) == CONST_STRING)
+   else if (CONST_STRING_P (rtl))
  {
expansion_failed (loc, NULL_RTX, "CONST_STRING");
return 0;
@@ -19687,7 +19687,7 @@ add_const_value_attribute (dw_die_ref die, rtx rtl)
   return false;
 
 case MEM:
-  if (GET_CODE (XEXP (rtl, 0)) == CONST_STRING
+  if (CONST_STRING_P (XEXP (rtl, 0))
  && MEM_READONLY_P (rtl)
  && GET_MODE (rtl) == BLKmode)
{
@@ -20165,7 +20165,7 @@ add_location_or_const_value_attribute (dw_die_ref die, 
tree decl, bool cache_p)
  the location.  */
 
   rtl = rtl_for_decl_location (decl);
-  if (rtl && (CONSTANT_P (rtl) || GET_CODE (rtl) == CONST_STRING)
+  if (rtl && (CONSTANT_P (rtl) || CONST_STRING_P (rtl))
   && add_const_value_attribute (die, rtl))
 return true;
 
@@ -20186,7 +20186,7 @@ add_location_or_const_value_attribute (dw_die_ref die, 
tree decl, bool cache_p)
   rtl = NOTE_VAR_LOCATION_LOC (node->loc);
   if (GET_CODE (rtl) == EXPR_LIST)
rtl = XEXP (rtl, 0);
-  if ((CONSTANT_P (rtl) || GET_CODE (rtl) == CONST_STRING)
+  if ((CONSTANT_P (rtl) || CONST_STRING_P (rtl))
  && add_const_value_attribute (die, rtl))
 return true;
 }
@@ -29855,7 +29855,7 @@ resolve_one_addr (rtx *addr)
 {
   rtx rtl = *addr;
 
-  if (GET_CODE (rtl) == CONST_STRING)
+  if (CONST_STRING_P (rtl))
 {
   size_t len = strlen (XSTR (rtl, 0)) + 1;
   tree t = build_string (len, XSTR (rtl, 0));
@@ -29960,7 +29960,7 @@ optimize_one_addr_into_implicit_ptr (dw_loc_descr_ref 
loc)
   offset = INTVAL (XEXP (XEXP (rtl, 0), 1));
   rtl = XEXP (XEXP (rtl, 0), 0);
 }
-  if (GET_CODE (rtl) == CONST_STRING)
+  if (CONST_STRING_P (rtl))
 {
   size_t len = strlen (XSTR (rtl, 0)) + 1;
   tree t = build_string (len, XSTR (rtl, 0));
diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c
index cdf0b5c12dc..6b24323f112 100644
--- a/gcc/genattrtab.c
+++ b/gcc/genattrtab.c
@@ -739,7 +739,7 @@ check_attr_test (file_location loc, rtx exp, attr_desc 
*attr)
  else
{
  for (av = attr2->first_value; av; av = av->next)
-   if (GET_CODE (av->value) == CONST_STRING
+   if (CONST_STRING_P (av->value)
&& ! strcmp (XSTR (exp, 1), XSTR (av->value, 0)))
  break;
 
@@ -892,7 +892,7 @@ check_attr_value (file_location loc, rtx exp, class 
attr_desc *attr)
}
 
   for (av = attr->first_value; av; av = av->next)
-   if (GET_CODE (av->value) == CONST_STRING
+   if (CONST_STRING_P (av->value)
&& ! strcmp (XSTR (av->value, 0), XSTR (exp, 0)))
  break;
 
@@ -5000,7 +5000,7 @@ make_automaton_attrs (void)
{
  if (val == tune_attr->default_val)
continue;
- gcc_assert (GET_CODE (val->value) == CONST_STRING);
+ gcc_assert (CONST_STRING_P (val->value));
  fprintf (dfa_file,
   "extern int internal_dfa_insn_code_%s (rtx_insn *);\n",
   XSTR (val->value, 0));
@@ -5012,7 +5012,7 @@ make_automaton_attrs (void)
{
  if (val == tune_attr->default_val)
continue;
- gcc_assert (GET_CODE (val->value) == CONST_STRING);
+ gcc_assert (CONST_STRING_P (val->value));
  fprintf (latency_file,
   "extern int insn_default_latency_%s (rtx_insn *);\n",
   XSTR (val->value, 0));
@@ -5024,7 +5024,7 @@ make_automaton_attrs (void)
{
  if (val == tune_attr->default_val)
continue;
- gcc_assert (GET_CODE (val->value) == CONST_STRING);
+

[PATCH v2 05/18] Use CONST_FIXED_P macro. Autogenerated patch by running ../contrib/rtl-pred.sh CONST_FIXED

2019-08-05 Thread Arvind Sankar
2019-08-05  Arvind Sankar  

gcc/ChangeLog:

* cfgexpand.c: Convert GET_CODE (..) == CONST_FIXED
to CONST_FIXED_P.
* config/spu/spu.c: Likewise.
* varasm.c: Likewise.

 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 33af991573f..b141a57d3af 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -5481,7 +5481,7 @@ expand_debug_locations (void)
gcc_assert (mode == GET_MODE (val)
|| (GET_MODE (val) == VOIDmode
&& (CONST_SCALAR_INT_P (val)
-   || GET_CODE (val) == CONST_FIXED
+   || CONST_FIXED_P (val)
|| GET_CODE (val) == LABEL_REF)));
  }
 
diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c
index 0e21e28b2e7..e6b25ab3b98 100644
--- a/gcc/config/spu/spu.c
+++ b/gcc/config/spu/spu.c
@@ -5985,7 +5985,7 @@ spu_expand_vector_init (rtx target, rtx vals)
   x = XVECEXP (vals, 0, i);
   if (!(CONST_INT_P (x)
|| GET_CODE (x) == CONST_DOUBLE
-   || GET_CODE (x) == CONST_FIXED))
+   || CONST_FIXED_P (x)))
++n_var;
   else
{
@@ -6026,7 +6026,7 @@ spu_expand_vector_init (rtx target, rtx vals)
  x = XVECEXP (constant_parts_rtx, 0, i);
  if (!(CONST_INT_P (x)
|| GET_CODE (x) == CONST_DOUBLE
-   || GET_CODE (x) == CONST_FIXED))
+   || CONST_FIXED_P (x)))
XVECEXP (constant_parts_rtx, 0, i) = first_constant;
}
 
@@ -6046,7 +6046,7 @@ spu_expand_vector_init (rtx target, rtx vals)
  x = XVECEXP (vals, 0, i);
  if (!(CONST_INT_P (x)
|| GET_CODE (x) == CONST_DOUBLE
-   || GET_CODE (x) == CONST_FIXED))
+   || CONST_FIXED_P (x)))
{
  if (!register_operand (x, GET_MODE (x)))
x = force_reg (GET_MODE (x), x);
diff --git a/gcc/varasm.c b/gcc/varasm.c
index e886cdc71b8..0e833b9bc58 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -2813,7 +2813,7 @@ assemble_integer (rtx x, unsigned int size, unsigned int 
align, int force)
 
   subsize = size > UNITS_PER_WORD? UNITS_PER_WORD : 1;
   subalign = MIN (align, subsize * BITS_PER_UNIT);
-  if (GET_CODE (x) == CONST_FIXED)
+  if (CONST_FIXED_P (x))
mclass = GET_MODE_CLASS (GET_MODE (x));
   else
mclass = MODE_INT;
-- 
2.21.0



[PATCH v2 15/18] Use LABEL_REF_P macro.

2019-08-05 Thread Arvind Sankar
2019-08-05  Arvind Sankar  

gcc/ChangeLog:

* rtlanal.c: Convert GET_CODE (..) == LABEL_REF to
LABEL_REF_P (..).

 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index cb6c8902353..a8becc85047 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -3347,8 +3347,7 @@ computed_jump_p (const rtx_insn *insn)
 
  for (i = len - 1; i >= 0; i--)
if (GET_CODE (XVECEXP (pat, 0, i)) == USE
-   && (GET_CODE (XEXP (XVECEXP (pat, 0, i), 0))
-   == LABEL_REF))
+   && LABEL_REF_P (XEXP (XVECEXP (pat, 0, i), 0)))
  {
has_use_labelref = 1;
break;
-- 
2.21.0



[PATCH v2 09/18] Add CONST_STRING_P rtx_code predicate.

2019-08-05 Thread Arvind Sankar
2019-08-05  Arvind Sankar  

gcc/ChangeLog:

* rtl.h: Add a predicate macro for checking CONST_STRING.

 1 file changed, 3 insertions(+)

diff --git a/gcc/rtl.h b/gcc/rtl.h
index 45e2b85867d..d02772b65be 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -821,6 +821,9 @@ struct GTY(()) rtvec_def {
 /* Predicate yielding nonzero iff X is an rtx for a vector const.  */
 #define CONST_VECTOR_P(X) (GET_CODE (X) == CONST_VECTOR)
 
+/* Predicate yielding nonzero iff X is an rtx for an rtl string const.  */
+#define CONST_STRING_P(X) (GET_CODE (X) == CONST_STRING)
+
 /* Predicate yielding true iff X is an rtx for a integer const.  */
 #if TARGET_SUPPORTS_WIDE_INT
 #define CONST_SCALAR_INT_P(X) \
-- 
2.21.0



[PATCH v2 06/18] Use CONST_DOUBLE_P macro. Autogenerated patch by running ../contrib/rtl-pred.sh CONST_DOUBLE

2019-08-05 Thread Arvind Sankar
2019-08-05  Arvind Sankar  

gcc/ChangeLog:

* config/aarch64/aarch64.c: Convert
GET_CODE (..) == CONST_DOUBLE to CONST_DOUBLE_P (..).
* config/aarch64/aarch64.md: Likewise.
* config/arc/arc.c: Likewise.
* config/arc/arc.md: Likewise.
* config/arc/fpx.md: Likewise.
* config/bfin/bfin.md: Likewise.
* config/c6x/c6x.h: Likewise.
* config/c6x/c6x.md: Likewise.
* config/cr16/predicates.md: Likewise.
* config/cris/cris.c: Likewise.
* config/cris/cris.md: Likewise.
* config/csky/csky.c: Likewise.
* config/darwin.c: Likewise.
* config/fr30/fr30.c: Likewise.
* config/frv/frv.c: Likewise.
* config/frv/frv.h: Likewise.
* config/gcn/gcn-valu.md: Likewise.
* config/gcn/gcn.c: Likewise.
* config/ia64/ia64.c: Likewise.
* config/ia64/vect.md: Likewise.
* config/iq2000/iq2000.md: Likewise.
* config/lm32/lm32.c: Likewise.
* config/m32r/m32r.c: Likewise.
* config/m68k/m68k.c: Likewise.
* config/m68k/m68k.md: Likewise.
* config/m68k/predicates.md: Likewise.
* config/mcore/mcore.c: Likewise.
* config/microblaze/microblaze.c: Likewise.
* config/mips/mips.c: Likewise.
* config/mips/mips.md: Likewise.
* config/mmix/mmix.c: Likewise.
* config/mmix/predicates.md: Likewise.
* config/nds32/constraints.md: Likewise.
* config/nds32/nds32-predicates.c: Likewise.
* config/nds32/nds32.c: Likewise.
* config/nds32/nds32.h: Likewise.
* config/pa/pa.c: Likewise.
* config/pa/pa.md: Likewise.
* config/pdp11/pdp11.c: Likewise.
* config/s390/s390.c: Likewise.
* config/sh/sh.c: Likewise.
* config/sh/sh.h: Likewise.
* config/sparc/predicates.md: Likewise.
* config/sparc/sparc.c: Likewise.
* config/sparc/sparc.md: Likewise.
* config/spu/predicates.md: Likewise.
* config/spu/spu.c: Likewise.
* config/tilegx/tilegx.c: Likewise.
* config/tilepro/tilepro.c: Likewise.
* config/v850/predicates.md: Likewise.
* config/v850/v850.c: Likewise.
* config/vax/vax.c: Likewise.
* config/vax/vax.md: Likewise.
* config/visium/visium.c: Likewise.
* config/xtensa/xtensa.c: Likewise.
* defaults.h: Likewise.
* genpreds.c: Likewise.
* recog.c: Likewise.
* reg-stack.c: Likewise.

 59 files changed, 161 insertions(+), 161 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index a526b8be522..68ad4858c76 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -7057,7 +7057,7 @@ aarch64_reinterpret_float_as_int (rtx value, unsigned 
HOST_WIDE_INT *intval)
 }
 
   scalar_float_mode mode;
-  if (GET_CODE (value) != CONST_DOUBLE
+  if (!CONST_DOUBLE_P (value)
   || !is_a  (GET_MODE (value), &mode)
   || GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT
   /* Only support up to DF mode.  */
@@ -7097,7 +7097,7 @@ aarch64_float_const_rtx_p (rtx x)
  mov/movk pairs over ldr/adrp pairs.  */
   unsigned HOST_WIDE_INT ival;
 
-  if (GET_CODE (x) == CONST_DOUBLE
+  if (CONST_DOUBLE_P (x)
   && SCALAR_FLOAT_MODE_P (mode)
   && aarch64_reinterpret_float_as_int (x, &ival))
 {
@@ -7136,7 +7136,7 @@ aarch64_can_const_movi_rtx_p (rtx x, machine_mode mode)
   scalar_int_mode imode;
   unsigned HOST_WIDE_INT ival;
 
-  if (GET_CODE (x) == CONST_DOUBLE
+  if (CONST_DOUBLE_P (x)
   && SCALAR_FLOAT_MODE_P (mode))
 {
   if (!aarch64_reinterpret_float_as_int (x, &ival))
@@ -14426,7 +14426,7 @@ aarch64_sve_float_arith_immediate_p (rtx x, bool 
negate_p)
   REAL_VALUE_TYPE r;
 
   if (!const_vec_duplicate_p (x, &elt)
-  || GET_CODE (elt) != CONST_DOUBLE)
+  || !CONST_DOUBLE_P (elt))
 return false;
 
   r = *CONST_DOUBLE_REAL_VALUE (elt);
@@ -14452,7 +14452,7 @@ aarch64_sve_float_mul_immediate_p (rtx x)
   /* GCC will never generate a multiply with an immediate of 2, so there is no
  point testing for it (even though it is a valid constant).  */
   return (const_vec_duplicate_p (x, &elt)
- && GET_CODE (elt) == CONST_DOUBLE
+ && CONST_DOUBLE_P (elt)
  && real_equal (CONST_DOUBLE_REAL_VALUE (elt), &dconsthalf));
 }
 
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index 873f2760cce..1fe96d5f772 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -1246,7 +1246,7 @@
   }
 
 if (GET_CODE (operands[0]) == MEM
-&& ! (GET_CODE (operands[1]) == CONST_DOUBLE
+&& ! (CONST_DOUBLE_P (operands[1])
  && aarch64_float_const_zero_rtx_p (operands[1])))
   operands[1] = force_reg (mode, operands[1]);
   }
d

[PATCH v2 14/18] Use LABEL_REF_P macro. Autogenerated patch by running ../contrib/rtl-pred.sh LABEL_REF

2019-08-05 Thread Arvind Sankar
2019-08-05  Arvind Sankar  

gcc/ChangeLog:

* alias.c: Convert GET_CODE (..) == LABEL_REF to
LABEL_REF_P (..).
* bb-reorder.c: Likewise.
* cfgbuild.c: Likewise.
* cfgexpand.c: Likewise.
* cfgrtl.c: Likewise.
* combine.c: Likewise.
* config/aarch64/aarch64.c: Likewise.
* config/alpha/predicates.md: Likewise.
* config/arc/arc.c: Likewise.
* config/arc/arc.h: Likewise.
* config/arm/arm.c: Likewise.
* config/arm/thumb1.md: Likewise.
* config/avr/avr.c: Likewise.
* config/bfin/bfin.c: Likewise.
* config/bfin/bfin.h: Likewise.
* config/bfin/predicates.md: Likewise.
* config/c6x/c6x.c: Likewise.
* config/c6x/c6x.md: Likewise.
* config/c6x/predicates.md: Likewise.
* config/cr16/cr16.c: Likewise.
* config/cr16/cr16.h: Likewise.
* config/cris/cris.c: Likewise.
* config/cris/cris.md: Likewise.
* config/csky/constraints.md: Likewise.
* config/csky/csky.c: Likewise.
* config/csky/csky.h: Likewise.
* config/darwin.c: Likewise.
* config/epiphany/epiphany.h: Likewise.
* config/epiphany/predicates.md: Likewise.
* config/frv/frv.c: Likewise.
* config/frv/predicates.md: Likewise.
* config/ft32/constraints.md: Likewise.
* config/ft32/ft32.c: Likewise.
* config/ft32/ft32.md: Likewise.
* config/ft32/predicates.md: Likewise.
* config/gcn/gcn.c: Likewise.
* config/gcn/gcn.md: Likewise.
* config/h8300/h8300.h: Likewise.
* config/i386/i386.c: Likewise.
* config/i386/i386.h: Likewise.
* config/i386/i386.md: Likewise.
* config/i386/predicates.md: Likewise.
* config/iq2000/iq2000.c: Likewise.
* config/iq2000/iq2000.h: Likewise.
* config/iq2000/predicates.md: Likewise.
* config/lm32/lm32.c: Likewise.
* config/lm32/lm32.h: Likewise.
* config/lm32/lm32.md: Likewise.
* config/m32r/constraints.md: Likewise.
* config/m32r/m32r.c: Likewise.
* config/m32r/m32r.h: Likewise.
* config/m32r/predicates.md: Likewise.
* config/m68k/constraints.md: Likewise.
* config/m68k/m68k.c: Likewise.
* config/m68k/m68k.h: Likewise.
* config/m68k/predicates.md: Likewise.
* config/mcore/constraints.md: Likewise.
* config/mcore/mcore.c: Likewise.
* config/mcore/mcore.h: Likewise.
* config/mcore/predicates.md: Likewise.
* config/microblaze/microblaze.c: Likewise.
* config/microblaze/predicates.md: Likewise.
* config/mips/mips.c: Likewise.
* config/mmix/mmix.c: Likewise.
* config/mmix/predicates.md: Likewise.
* config/mn10300/mn10300.c: Likewise.
* config/mn10300/mn10300.h: Likewise.
* config/moxie/constraints.md: Likewise.
* config/moxie/moxie.c: Likewise.
* config/moxie/predicates.md: Likewise.
* config/nds32/nds32-cost.c: Likewise.
* config/nds32/nds32-md-auxiliary.c: Likewise.
* config/nds32/nds32.h: Likewise.
* config/nios2/nios2.c: Likewise.
* config/nvptx/nvptx.c: Likewise.
* config/nvptx/nvptx.md: Likewise.
* config/pa/pa.c: Likewise.
* config/pa/pa.h: Likewise.
* config/pa/pa.md: Likewise.
* config/pa/predicates.md: Likewise.
* config/riscv/riscv.c: Likewise.
* config/rs6000/freebsd64.h: Likewise.
* config/rs6000/linux64.h: Likewise.
* config/rs6000/rs6000.c: Likewise.
* config/rs6000/rs6000.h: Likewise.
* config/rs6000/rtems.h: Likewise.
* config/rs6000/sysv4.h: Likewise.
* config/rs6000/xcoff.h: Likewise.
* config/rx/rx.c: Likewise.
* config/s390/predicates.md: Likewise.
* config/s390/s390.c: Likewise.
* config/s390/s390.h: Likewise.
* config/sh/predicates.md: Likewise.
* config/sh/sh.c: Likewise.
* config/sh/sh.h: Likewise.
* config/sparc/predicates.md: Likewise.
* config/sparc/sparc.c: Likewise.
* config/sparc/sparc.md: Likewise.
* config/spu/constraints.md: Likewise.
* config/spu/spu.c: Likewise.
* config/tilegx/predicates.md: Likewise.
* config/tilegx/tilegx.c: Likewise.
* config/tilepro/predicates.md: Likewise.
* config/tilepro/tilepro.c: Likewise.
* config/v850/v850.c: Likewise.
* config/vax/predicates.md: Likewise.
* config/vax/vax.c: Likewise.
* config/xtensa/xtensa.c: Likewise.
* config/xtensa/xtensa.h: Likewise.
* cprop.c: Likewise.
* cse.c: Likewise.
* dbxout.c: Likewise.
* explow.c: Likewise.
* expr.c: Likewise.
* final.c: Likewise.
* genattrtab.c: Likewise.
* gensupport.c: Likewise.
* ifcvt.c

[PATCH v2 17/18] Use SYMBOL_REF_P macro.

2019-08-05 Thread Arvind Sankar
2019-08-05  Arvind Sankar  

gcc/ChangeLog:

* dwarf2out.c: Convert GET_CODE (..) == SYMBOL_REF to
SYMBOL_REF_P (..).

 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index b2b4f6d82b2..ea38963d177 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -23747,8 +23747,7 @@ gen_variable_die (tree decl, tree origin, dw_die_ref 
context_die)
  if (single_element_loc_list_p (loc)
  && loc->expr->dw_loc_opc == DW_OP_addr
  && loc->expr->dw_loc_next == NULL
- && GET_CODE (loc->expr->dw_loc_oprnd1.v.val_addr)
-== SYMBOL_REF)
+ && SYMBOL_REF_P (loc->expr->dw_loc_oprnd1.v.val_addr))
{
  rtx x = loc->expr->dw_loc_oprnd1.v.val_addr;
  loc->expr->dw_loc_oprnd1.v.val_addr
-- 
2.21.0



[PATCH v2 18/18] Use DEBUG_INSN_P macro. Autogenerated patch by running ../contrib/rtl-pred.sh DEBUG_INSN_P

2019-08-05 Thread Arvind Sankar
2019-08-05  Arvind Sankar  

gcc/ChangeLog:

* reload1.c: Convert GET_CODE (..) == DEBUG_INSN to
DEBUG_INSN_P (..).
* reorg.c: Likewise.

 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/reload1.c b/gcc/reload1.c
index 1a68d0567fc..d30badc0c4f 100644
--- a/gcc/reload1.c
+++ b/gcc/reload1.c
@@ -2850,7 +2850,7 @@ eliminate_regs_1 (rtx x, machine_mode mem_mode, rtx insn,
  || known_eq (x_size, new_size))
  )
return adjust_address_nv (new_rtx, GET_MODE (x), SUBREG_BYTE (x));
- else if (insn && GET_CODE (insn) == DEBUG_INSN)
+ else if (insn && DEBUG_INSN_P (insn))
return gen_rtx_raw_SUBREG (GET_MODE (x), new_rtx, SUBREG_BYTE (x));
  else
return gen_rtx_SUBREG (GET_MODE (x), new_rtx, SUBREG_BYTE (x));
diff --git a/gcc/reorg.c b/gcc/reorg.c
index 79684952595..4ec3d7efea6 100644
--- a/gcc/reorg.c
+++ b/gcc/reorg.c
@@ -1510,7 +1510,7 @@ redundant_insn (rtx insn, rtx_insn *target, const 
vec &delay_list)
  || GET_CODE (pat) == CLOBBER_HIGH)
continue;
 
-  if (GET_CODE (trial) == DEBUG_INSN)
+  if (DEBUG_INSN_P (trial))
continue;
 
   if (rtx_sequence *seq = dyn_cast  (pat))
@@ -1609,7 +1609,7 @@ redundant_insn (rtx insn, rtx_insn *target, const 
vec &delay_list)
  || GET_CODE (pat) == CLOBBER_HIGH)
continue;
 
-  if (GET_CODE (trial) == DEBUG_INSN)
+  if (DEBUG_INSN_P (trial))
continue;
 
   if (rtx_sequence *seq = dyn_cast  (pat))
@@ -2047,7 +2047,7 @@ fill_simple_delay_slots (int non_jumps_p)
continue;
 
  /* And DEBUG_INSNs never go into delay slots.  */
- if (GET_CODE (trial) == DEBUG_INSN)
+ if (DEBUG_INSN_P (trial))
continue;
 
  /* Check for resource conflict first, to avoid unnecessary
@@ -2174,7 +2174,7 @@ fill_simple_delay_slots (int non_jumps_p)
continue;
 
  /* And DEBUG_INSNs do not go in delay slots.  */
- if (GET_CODE (trial) == DEBUG_INSN)
+ if (DEBUG_INSN_P (trial))
continue;
 
  /* If this already has filled delay slots, get the insn needing
@@ -2442,7 +2442,7 @@ fill_slots_from_thread (rtx_jump_insn *insn, rtx 
condition,
  || GET_CODE (pat) == CLOBBER_HIGH)
continue;
 
-  if (GET_CODE (trial) == DEBUG_INSN)
+  if (DEBUG_INSN_P (trial))
continue;
 
   /* If TRIAL conflicts with the insns ahead of it, we lose.  Also,
-- 
2.21.0



Re: Use predicates for RTL objects

2019-08-08 Thread Arvind Sankar
On Thu, Aug 08, 2019 at 10:42:06AM -0600, Jeff Law wrote:
> On 8/5/19 12:29 PM, Segher Boessenkool wrote:
> > On Mon, Aug 05, 2019 at 02:14:50PM -0400, Arvind Sankar wrote:
> >> On Mon, Aug 05, 2019 at 12:48:46PM -0500, Segher Boessenkool wrote:
> >>> First: do you have a copyright assignment?  See
> >>>   https://gcc.gnu.org/contribute.html
> >>> for instructions.
> >>
> >> Nope, is this really substantial enough to warrant one?
> > 
> > Some might say it is, the sheer amount of code changed :-)  If some
> > maintainer okays it without assignment, that is fine with me of course.
> > 
> > This is also easier if it is all machine-generated and nice simple
> > patches :-)
> If it's entirely machine generated and you don't want to do a copyright
> assignment, then the way to go will be for someone with an assignment to
> run the scripts and commit the change.  Then we'd only need an
> assignment if we wanted the scripts in the repo.
> 
I have just got the forms from GNU, probably a few days to actually send
it in. I am not too fussed about how to do this particular change,
whatever's easiest.
> 
> 
> > 
> >>>> -/* Predicate yielding true iff X is an rtx for a double-int.  */
> >>>> +/* Predicate yielding true iff X is an rtx for a floating point 
> >>>> constant.  */
> >>>>  #define CONST_DOUBLE_AS_FLOAT_P(X) \
> >>>>(GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) != VOIDmode)
> >>>
> >>> Is const_double really only used for floating point these days?
> > 
> >> Are you asking if the CONST_DOUBLE_AS_INT_P possibility is dead code
> >> now? That's beyond my current level of understanding of the code,
> >> hopefully someone else will chime in.
> > 
> > I am asking if the change to this comment is correct.
> I thought we used CONST_DOUBLE for scalar constants that are wider than
> a HOST_WIDE_INT, or perhaps wider than 2 HOST_WIDE_INTs.  If that's
> still the case, then the comment change is wrong.
> 
> Jeff

Please note that this is the comment for CONST_DOUBLE_AS_FLOAT_P, not
CONST_DOUBLE_P. CONST_DOUBLE_AS_INT_P is the predicate to represent a
CONST_DOUBLE being used to store large integers, and, as I understand
it, it will be used if the target does not define TARGET_SUPPORTS_WIDE_INT.

At present, the comment for both CONST_DOUBLE_AS_INT_P and
CONST_DOUBLE_AS_FLOAT_P claim that they are the predicates for
double-int.


[PATCH] Use GCC_PICFLAG to collect host-specific PICFLAG from ../config/picflag.m4

2019-07-22 Thread Arvind Sankar
The gcc configure script does not use the config/picflag.m4 macro to
customize PICFLAG according to the host when using --enable-host-shared.

Fix configure.ac to do so.

Tested bootstrap on x86_64-linux-gnu.

2019-07-22  Arvind Sankar  

* gcc/configure.ac: Use GCC_PICFLAG.
---
 gcc/configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/configure.ac b/gcc/configure.ac
index c620dd2f447..f6bdfd52fa6 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -6543,7 +6543,7 @@ fi
 AC_ARG_ENABLE(host-shared,
 [AS_HELP_STRING([--enable-host-shared],
[build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
+[GCC_PICFLAG], [PICFLAG=])
 AC_SUBST(enable_host_shared)
 AC_SUBST(PICFLAG)
 
-- 
2.21.0


Re: [PATCH 0/3] add support for POD struct convention (PR 61339)

2019-07-23 Thread Arvind Sankar
Hi, SVN rev 273311 appears to have been committed without regenerating
gcc/config*?

Thanks.


Re: [PATCH 0/3] add support for POD struct convention (PR 61339)

2019-07-23 Thread Arvind Sankar
On Tue, Jul 23, 2019 at 10:31:16AM -0600, Martin Sebor wrote:
> On 7/23/19 10:11 AM, Arvind Sankar wrote:
> > Hi, SVN rev 273311 appears to have been committed without regenerating
> > gcc/config*?
> 
> That commit wasn't meant to change the configure script since
> the warning implementation isn't part of the patch.  Let me
> back it out.
> 
> Martin

Thanks


[PATCH] Fix typo LIBGCCJIT_SYMLINK -> LIBGCCJIT_SONAME_SYMLINK

2019-07-23 Thread Arvind Sankar
There seems to be a typo in gcc/jit/Make-lang.in where it references an
undefined LIBGCCJIT_SYMLINK instead of LIBGCCJIT_SONAME_SYMLINK.
---
 gcc/jit/Make-lang.in | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in
index 660f54d78bd..5cfd6035d8c 100644
--- a/gcc/jit/Make-lang.in
+++ b/gcc/jit/Make-lang.in
@@ -65,7 +65,7 @@ LIBGCCJIT_SONAME_OPTION = \
 -Wl$(COMMA)$(LD_SONAME_OPTION)$(COMMA)$(LIBGCCJIT_SONAME))
 
 jit: $(LIBGCCJIT_FILENAME) \
-   $(LIBGCCJIT_SYMLINK) \
+   $(LIBGCCJIT_SONAME_SYMLINK) \
$(LIBGCCJIT_LINKER_NAME_SYMLINK) \
$(FULL_DRIVER_NAME)
 
@@ -301,9 +301,8 @@ jit.uninstall:
 # We just have to delete files specific to us.
 
 jit.mostlyclean:
-   -rm -f $(LIBGCCJIT_FILENAME) $(LIBGCCJIT_SYMLINK)
+   -rm -f $(LIBGCCJIT_FILENAME) $(LIBGCCJIT_SONAME_SYMLINK)
-rm -f $(LIBGCCJIT_LINKER_NAME_SYMLINK) $(FULL_DRIVER_NAME)
-   -rm -f $(LIBGCCJIT_SONAME)
-rm -f $(jit_OBJS)
 
 jit.clean:
-- 
2.21.0


Re: [PATCH] Fix typo LIBGCCJIT_SYMLINK -> LIBGCCJIT_SONAME_SYMLINK

2019-07-31 Thread Arvind Sankar
Hi any feedback on this?

Thanks.

On Tue, Jul 23, 2019 at 02:49:13PM -0400, Arvind Sankar wrote:
> There seems to be a typo in gcc/jit/Make-lang.in where it references an
> undefined LIBGCCJIT_SYMLINK instead of LIBGCCJIT_SONAME_SYMLINK.
> ---
>  gcc/jit/Make-lang.in | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in
> index 660f54d78bd..5cfd6035d8c 100644
> --- a/gcc/jit/Make-lang.in
> +++ b/gcc/jit/Make-lang.in
> @@ -65,7 +65,7 @@ LIBGCCJIT_SONAME_OPTION = \
>-Wl$(COMMA)$(LD_SONAME_OPTION)$(COMMA)$(LIBGCCJIT_SONAME))
>  
>  jit: $(LIBGCCJIT_FILENAME) \
> - $(LIBGCCJIT_SYMLINK) \
> + $(LIBGCCJIT_SONAME_SYMLINK) \
>   $(LIBGCCJIT_LINKER_NAME_SYMLINK) \
>   $(FULL_DRIVER_NAME)
>  
> @@ -301,9 +301,8 @@ jit.uninstall:
>  # We just have to delete files specific to us.
>  
>  jit.mostlyclean:
> - -rm -f $(LIBGCCJIT_FILENAME) $(LIBGCCJIT_SYMLINK)
> + -rm -f $(LIBGCCJIT_FILENAME) $(LIBGCCJIT_SONAME_SYMLINK)
>   -rm -f $(LIBGCCJIT_LINKER_NAME_SYMLINK) $(FULL_DRIVER_NAME)
> - -rm -f $(LIBGCCJIT_SONAME)
>   -rm -f $(jit_OBJS)
>  
>  jit.clean:
> -- 
> 2.21.0


[PATCH] Fix typo LIBGCCJIT_SYMLINK -> LIBGCCJIT_SONAME_SYMLINK

2019-08-01 Thread Arvind Sankar
Resending and adding the jit list.

There seems to be a typo in gcc/jit/Make-lang.in where it references an
undefined LIBGCCJIT_SYMLINK instead of LIBGCCJIT_SONAME_SYMLINK.
---
 gcc/jit/Make-lang.in | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in
index 660f54d78bd..5cfd6035d8c 100644
--- a/gcc/jit/Make-lang.in
+++ b/gcc/jit/Make-lang.in
@@ -65,7 +65,7 @@ LIBGCCJIT_SONAME_OPTION = \
 -Wl$(COMMA)$(LD_SONAME_OPTION)$(COMMA)$(LIBGCCJIT_SONAME))
 
 jit: $(LIBGCCJIT_FILENAME) \
-   $(LIBGCCJIT_SYMLINK) \
+   $(LIBGCCJIT_SONAME_SYMLINK) \
$(LIBGCCJIT_LINKER_NAME_SYMLINK) \
$(FULL_DRIVER_NAME)
 
@@ -301,9 +301,8 @@ jit.uninstall:
 # We just have to delete files specific to us.
 
 jit.mostlyclean:
-   -rm -f $(LIBGCCJIT_FILENAME) $(LIBGCCJIT_SYMLINK)
+   -rm -f $(LIBGCCJIT_FILENAME) $(LIBGCCJIT_SONAME_SYMLINK)
-rm -f $(LIBGCCJIT_LINKER_NAME_SYMLINK) $(FULL_DRIVER_NAME)
-   -rm -f $(LIBGCCJIT_SONAME)
-rm -f $(jit_OBJS)
 
 jit.clean:
-- 
2.21.0


Re: Use predicates for RTL objects

2019-08-02 Thread Arvind Sankar
On Fri, Aug 02, 2019 at 12:49:56PM -0500, Segher Boessenkool wrote:
> On Fri, Aug 02, 2019 at 01:38:21PM -0400, Arvind Sankar wrote:
> > Hi, I have taken a crack at the beginner GCC project mentioned at
> > https://gcc.gnu.org/projects/beginner.html to replace uses of GET_CODE
> > to check rtx_code with the appropriate predicate macros.
> > 
> > Would someone be able to review/actually apply the changes if they look
> > acceptable?
> > 
> > Most of the change is auto-generated using the enclosed script [1]. In
> > addition I have added 3 new predicates to rtl.h: CONST_VECTOR_P,
> > CONST_STRING_P and CONST_P. After the autogenned patch there is a small
> > cleanup for a couple instances where the existing comparison is split
> > across source lines and wasn't picked up by the script.
> 
> Thank you for doing this!
> 
> I don't think there should be a CONST_P like this, the name suggests
> too much that the macro returns true for constants, which isn't what it
> does (not in either direction; neither more or less than it).
> 
> It's worse than SET_P or PLUS_P would be even, imo.
> 
> Maybe you can put a script like this in contrib/ ?
> 
> 
> Segher

Yes, I agree CONST_P is a little confusing. There are about 60
occurences of GET_CODE (..) being compared to CONST in generic code.
Should I just leave it out of the conversion or perhaps rename it to
RTL_CONST_P? Though none of the other macros is namespaced, unfortunately.

Thanks.


[RFC PATCH] Enhancements to profiledbootstrap

2019-05-16 Thread Arvind Sankar
Hi, I've been playing some with the PGO build infrastructure and have a
few changes I thought I'd share and get feedback on whether they're
completely crazy or not. I'm not terribly familiar with the innards of
the build infra, so would appreciate any comments and suggestions.

First, a recap of the current PGO build process -- please let me know if
I'm wrong about anything:
For a profiledbootstrap build, we replace normal stage{2,3,4}
resepectively with an instrumented stageprofile, a non-instrumented
stagetrain and finally a stagefeedback using the profile created when
building stagetrain.

I had two main goals in doing these changes:
1. profiledbootstrap does not do any comparison build, unlike the
regular bootstrap, so it is possible that the end product is actually
broken. Goal 1: try to incorporate this.
2. The profiling data comes from the stageprofile -> stagetrain build
and that run does not include many optimization passes (at least by
default at -O2) because those would only get enabled when profiling data
is available. Goal 2: try to create a bootstrap target that would
incorporate data from these passes.

Goal 1: Comparison stage
I started on goal 1 with the idea that if we built stagetrain with
instrumentation as well, we could just compare stageprofile and
stagetrain like we do with stage2/3.

This runs into a few roadblocks however that I would appreciate if
someone could comment on:
a) profiling data starts getting generated while building stageprofile,
since parts of that process involve running newly compiled executables.
In the current build that doesn't cause any issues, we just throw that
away and only use profiling data generated during the profile->train
build, which should be extensive enough.
This will not work if stagetrain is built with instrumentation,
as it will be appending profiling data to the same files that it is
using, during the train->feedback build. To resolve this, I changed the
build to save profiling data in an external directory, so the two stages
write profiling data into different places. Unfortunately, this results
in the path to that location getting saved into each object file, which
makes it impossible to compare them -- it should be possible to compare
just the .text sections maybe, or pass different GCOV_PREFIX overrides
for build vs host tools, but instead I decided to just add the
possibility to rebuild stagefeedback a second time using the
profile->train data and use that as the comparison, this should anyway
be the right comparison to do as it would be of the final build product.

It may also be possible to solve this by saving the profile data in the
same place for the two stages, but make a copy of that to use for the
train->feedback run but I haven't explored this yet. It will result in
profiling data that is a mix of the stageprofile and stagetrain
compilers but that might be okay given that they should be identical in
control flow.

b) I do get a few differences that are somewhat random: it looks like in
some cases the second run arranges functions in a different order from
the first run even though it is using the same profile data. Is this
known/is there a way to prevent it?

Goal 2: Second feedback stage
Nothing special here, it builds a new stagefeedbackfull using the
train->feedback profile. It does produce a different compiler so there's
some effect but I haven't benchmarked improvements to see if it's
measurably better.

Testing was done on x86_64-pc-linux-gnu, with default configure settings
except for --enable-languages=c,c++ --disable-werror. I've bootstrapped
PGO with/without --with-build-config=bootstrap-lto.

Summary of changes:
a) Add three new stages -- feedbackcompare, feedbackfull,
feedbackfullcompare with the two *compare stages to be used for
comparing with the previous ones. Question about gcc/*/Make-lang.in: I
see that these have rules at the end for, for eg c.stage*. Are these
necessary or vestegial-- stagetrain is not there currently and I didn't
add any of the new ones either.
b) Modify stagetrain to be built instrumented, and change profiling
output directories. Note that this is currently wasteful of build time
if you're going to stop with profiledbootstrap, so perhaps this should
be controlled via a build-config so it is enabled only for the *full
bootstraps.
c) Cleaned up bootstrap-lto{-lean}.mk a bit. It appears unnecessary to
set all the individual stage flags -- if someone wants to customize them
they can just override STAGE{2,3,4}_FLAGS to get the same effect. I also
added STAGE4_CFLAGS in there, and added -frandom-seed=1 and do-compare3
in bootstrap-lto-lean in case the user wants to do a bootstrap4. For
bootstrap-lto-noplugin.mk I noticed that the profiling stages were added
but without -ffat-lto-objects, that should get fixed by the patch
although it appears unlikely someone would be doing such a build.
d) If one does a non-LTO PGO build currently, the LTO frontend doesn't
get profiled. I modified the main Makefi

Re: [PATCH] Use GCC_PICFLAG to collect host-specific PICFLAG from ../config/picflag.m4

2020-06-10 Thread Arvind Sankar
On Wed, Jun 10, 2020 at 04:27:27PM -0600, Jeff Law wrote:
> On Mon, 2019-07-22 at 12:39 -0400, Arvind Sankar wrote:
> > The gcc configure script does not use the config/picflag.m4 macro to
> > customize PICFLAG according to the host when using --enable-host-shared.
> > 
> > Fix configure.ac to do so.
> > 
> > Tested bootstrap on x86_64-linux-gnu.
> > 
> > 2019-07-22  Arvind Sankar  
> > 
> > * gcc/configure.ac: Use GCC_PICFLAG.
> I know this is old
> 
> Can you be more specific here about what you're trying to fix?  ie, what
> host/target combination are you working on.  What behavior are you seeing
> (presumably usage of -fPIC) what behavior did you expect (some other flag
> presumably).
> 
> From looking at picflag.m4 the thing I worry the most about is the various
> ix86/x86_64 clauses which specify -fpic.  It looks like your change would 
> cause
> us to start using -fpic rather than -fPIC as we've been doing for eons and I
> worry that might have unintended consequences.
> 
> Thanks,
> Jeff
> > 
> 

I don't remember exactly, but I don't think there was any actual
problem. At the time, I was playing around with trying to build the bulk
of cc1 etc as a shared library to reduce the size of the compiler
installation. IIRC I just came across this, noticed that there's a
config/picflag.m4 which wasn't getting used and posted this as a
cleanup.

This was originally added in r177967 ("Centralize PICFLAG
configuration") which used it for PICFLAG_FOR_TARGET (which still goes
via config/picflag.m4) but the host code which was added later just
hardcodes -fPIC.