Re: [PATCH][rs6000] cleanup and rename rs6000_address_for_fpconvert

2018-11-01 Thread Segher Boessenkool
Hi!

On Thu, Nov 01, 2018 at 09:00:08AM -0500, Aaron Sawdey wrote:
>   (rs6000_address_for_fpconvert) Combine with
>   rs6000_force_indexed_or_indirect_mem.

(missing colon)

>  rtx
> -rs6000_address_for_fpconvert (rtx x)
> +rs6000_force_indexed_or_indirect_mem (rtx x)
>  {
> -  rtx addr;
> +  machine_mode m = GET_MODE (x);

Please spell this out, "mode".

Okay for trunk.  Thank you for doing this cleanup!


Segher


[PATCH][rs6000] cleanup and rename rs6000_address_for_fpconvert

2018-11-01 Thread Aaron Sawdey
This patch combines the duties of rs6000_address_for_fpconvert into
rs6000_force_indexed_or_indirect_mem which I recently added, and changes
all calls to use the latter. The new function name is more descriptive of what
is actually going on. This now uses indexed_or_indirect_operand() to test
the incoming rtx which matches what the insns this is used to prepare for
are using as their predicate.

Bootstrap/regtest passes on ppc64le (power7, power9), ok for trunk?



2018-11-01  Aaron Sawdey  

* config/rs6000/rs6000-protos.h (rs6000_address_for_fpconvert): Remove
prototype.
* config/rs6000/rs6000.c (rs6000_force_indexed_or_indirect_mem):
Combine with rs6000_address_for_fpconvert.
(rs6000_address_for_fpconvert) Combine with
rs6000_force_indexed_or_indirect_mem.
(rs6000_expand_vector_init): Change function call from
rs6000_address_for_fpconvert to rs6000_force_indexed_or_indirect_mem.
* config/rs6000/rs6000.md (floatsi2_lfiwax): Change call from
rs6000_address_for_fpconvert to rs6000_force_indexed_or_indirect_mem.
(floatsi2_lfiwax_mem): Ditto.
(floatunssi2_lfiwzx): Ditto.
(floatunssi2_lfiwzx_mem): Ditto.
(float2): Ditto.
(floatuns2): Ditto.
(fix_truncsi2_stfiwx): Ditto.
(fixuns_truncsi2_stfiwx): Ditto.
(float_si2_hw): Ditto.
(floatuns_si2_hw): Ditto.
* config/rs6000/vsx.md (*vsx_extract_si): Ditto.
(vsx_splat_): Ditto.




Index: gcc/config/rs6000/rs6000-protos.h
===
--- gcc/config/rs6000/rs6000-protos.h   (revision 265637)
+++ gcc/config/rs6000/rs6000-protos.h   (working copy)
@@ -153,7 +153,6 @@

 extern rtx rs6000_machopic_legitimize_pic_address (rtx, machine_mode,
   rtx);
-extern rtx rs6000_address_for_fpconvert (rtx);
 extern rtx rs6000_allocate_stack_temp (machine_mode, bool, bool);
 extern align_flags rs6000_loop_align (rtx);
 extern void rs6000_split_logical (rtx [], enum rtx_code, bool, bool, bool);
Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 265637)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -6560,7 +6560,7 @@
{
  rtx element0 = XVECEXP (vals, 0, 0);
  if (MEM_P (element0))
-   element0 = rs6000_address_for_fpconvert (element0);
+   element0 = rs6000_force_indexed_or_indirect_mem (element0);
  else
element0 = force_reg (SImode, element0);

@@ -6601,7 +6601,7 @@
  if (TARGET_P9_VECTOR)
{
  if (MEM_P (element0))
-   element0 = rs6000_address_for_fpconvert (element0);
+   element0 = rs6000_force_indexed_or_indirect_mem (element0);

  emit_insn (gen_vsx_splat_v4sf (target, element0));
}
@@ -8423,23 +8423,6 @@
   return false;
 }

-/* Helper function for making sure we will make full
-   use of indexed addressing.  */
-
-rtx
-rs6000_force_indexed_or_indirect_mem (rtx x)
-{
-  machine_mode m = GET_MODE (x);
-  if (!indexed_or_indirect_operand (x, m))
-{
-  rtx addr = XEXP (x, 0);
-  addr = force_reg (Pmode, addr);
-  x = replace_equiv_address_nv (x, addr);
-}
-  return x;
-}
-
-
 /* Implement the TARGET_LEGITIMATE_COMBINED_INSN hook.  */

 static bool
@@ -37312,21 +37295,19 @@
   return stack;
 }

-/* Given a memory reference, if it is not a reg or reg+reg addressing, convert
-   to such a form to deal with memory reference instructions like STFIWX that
-   only take reg+reg addressing.  */
+/* Given a memory reference, if it is not a reg or reg+reg addressing,
+   convert to such a form to deal with memory reference instructions
+   like STFIWX and LDBRX that only take reg+reg addressing.  */

 rtx
-rs6000_address_for_fpconvert (rtx x)
+rs6000_force_indexed_or_indirect_mem (rtx x)
 {
-  rtx addr;
+  machine_mode m = GET_MODE (x);

   gcc_assert (MEM_P (x));
-  addr = XEXP (x, 0);
-  if (can_create_pseudo_p ()
-  && ! legitimate_indirect_address_p (addr, reload_completed)
-  && ! legitimate_indexed_address_p (addr, reload_completed))
+  if (can_create_pseudo_p () && !indexed_or_indirect_operand (x, m))
 {
+  rtx addr = XEXP (x, 0);
   if (GET_CODE (addr) == PRE_INC || GET_CODE (addr) == PRE_DEC)
{
  rtx reg = XEXP (addr, 0);
@@ -37346,7 +37327,7 @@
  addr = reg;
}

-  x = replace_equiv_address (x, copy_addr_to_reg (addr));
+  x = replace_equiv_address (x, force_reg (Pmode, addr));
 }

   return x;
Index: gcc/config/rs6000/rs6000.md
===
--- gcc/config/rs6000/rs6000.md (revision 265637)
+++ gcc/config/rs6000/rs6000.md (working copy)
@@ -5225,7 +5225,7 @@
tmp = gen_reg_rtx (DImode);
   if (MEM_P (src))
{
- src =