[1/2] cselib: Keep track of further subvalue relations

Message ID 20220907142026.936922-2-stefansf@linux.ibm.com
State New, archived
Headers
Series Variable tracking and subvalues |

Commit Message

Stefan Schulze Frielinghaus Sept. 7, 2022, 2:20 p.m. UTC
  Whenever a new cselib value is created check whether a smaller value
exists which is contained in the bigger one.  If so add a subreg
relation to locs of the smaller one.

gcc/ChangeLog:

	* cselib.cc (new_cselib_val): Keep track of further subvalue
	relations.
---
 gcc/cselib.cc | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
  

Comments

Stefan Schulze Frielinghaus Sept. 26, 2022, 6:10 a.m. UTC | #1
Ping.

On Wed, Sep 07, 2022 at 04:20:25PM +0200, Stefan Schulze Frielinghaus wrote:
> Whenever a new cselib value is created check whether a smaller value
> exists which is contained in the bigger one.  If so add a subreg
> relation to locs of the smaller one.
> 
> gcc/ChangeLog:
> 
> 	* cselib.cc (new_cselib_val): Keep track of further subvalue
> 	relations.
> ---
>  gcc/cselib.cc | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/gcc/cselib.cc b/gcc/cselib.cc
> index 6a5609786fa..9b582e5d3d6 100644
> --- a/gcc/cselib.cc
> +++ b/gcc/cselib.cc
> @@ -1569,6 +1569,26 @@ new_cselib_val (unsigned int hash, machine_mode mode, rtx x)
>    e->locs = 0;
>    e->next_containing_mem = 0;
>  
> +  scalar_int_mode int_mode;
> +  if (REG_P (x) && is_int_mode (mode, &int_mode)
> +      && REG_VALUES (REGNO (x)) != NULL
> +      && (!cselib_current_insn || !DEBUG_INSN_P (cselib_current_insn)))
> +    {
> +      rtx copy = shallow_copy_rtx (x);
> +      scalar_int_mode narrow_mode_iter;
> +      FOR_EACH_MODE_UNTIL (narrow_mode_iter, int_mode)
> +	{
> +	  PUT_MODE_RAW (copy, narrow_mode_iter);
> +	  cselib_val *v = cselib_lookup (copy, narrow_mode_iter, 0, VOIDmode);
> +	  if (v)
> +	    {
> +	      rtx sub = lowpart_subreg (narrow_mode_iter, e->val_rtx, int_mode);
> +	      if (sub)
> +		new_elt_loc_list (v, sub);
> +	    }
> +	}
> +    }
> +
>    if (dump_file && (dump_flags & TDF_CSELIB))
>      {
>        fprintf (dump_file, "cselib value %u:%u ", e->uid, hash);
> -- 
> 2.37.2
>
  
Jeff Law Sept. 27, 2022, 11:46 p.m. UTC | #2
On 9/7/22 08:20, Stefan Schulze Frielinghaus via Gcc-patches wrote:
> Whenever a new cselib value is created check whether a smaller value
> exists which is contained in the bigger one.  If so add a subreg
> relation to locs of the smaller one.
>
> gcc/ChangeLog:
>
> 	* cselib.cc (new_cselib_val): Keep track of further subvalue
> 	relations.

OK

jeff
  
Joseph Myers Sept. 29, 2022, 5:40 p.m. UTC | #3
This introduces an ICE building libgcc for ia64-linux-gnu.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107088
https://sourceware.org/pipermail/libc-testresults/2022q3/010294.html
  

Patch

diff --git a/gcc/cselib.cc b/gcc/cselib.cc
index 6a5609786fa..9b582e5d3d6 100644
--- a/gcc/cselib.cc
+++ b/gcc/cselib.cc
@@ -1569,6 +1569,26 @@  new_cselib_val (unsigned int hash, machine_mode mode, rtx x)
   e->locs = 0;
   e->next_containing_mem = 0;
 
+  scalar_int_mode int_mode;
+  if (REG_P (x) && is_int_mode (mode, &int_mode)
+      && REG_VALUES (REGNO (x)) != NULL
+      && (!cselib_current_insn || !DEBUG_INSN_P (cselib_current_insn)))
+    {
+      rtx copy = shallow_copy_rtx (x);
+      scalar_int_mode narrow_mode_iter;
+      FOR_EACH_MODE_UNTIL (narrow_mode_iter, int_mode)
+	{
+	  PUT_MODE_RAW (copy, narrow_mode_iter);
+	  cselib_val *v = cselib_lookup (copy, narrow_mode_iter, 0, VOIDmode);
+	  if (v)
+	    {
+	      rtx sub = lowpart_subreg (narrow_mode_iter, e->val_rtx, int_mode);
+	      if (sub)
+		new_elt_loc_list (v, sub);
+	    }
+	}
+    }
+
   if (dump_file && (dump_flags & TDF_CSELIB))
     {
       fprintf (dump_file, "cselib value %u:%u ", e->uid, hash);