diff mbox

[v2] PR rtl-optimization/66790: uninitialized registers handling in REE

Message ID 561D2085.90802@adacore.com
State New
Headers show

Commit Message

Pierre-Marie de Rodat Oct. 13, 2015, 3:17 p.m. UTC
Hello,

The first attached patch is the second attempt to fix PR 
rtl-optimization/66790 (see 
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66790>).

The second one is a fix for some inconsistency noticed while working on 
the original bug. This specific patch fixes no known bug, but anyway…

Both were bootstrapped and regtested on x86_64-linux. Ok to commit? 
Thank you in advance!

[PATCH 1/2] REE: fix uninitialized registers handling

gcc/ChangeLog:

         PR rtl-optimization/66790
         * df.h (DF_MIR): New macro.
         (DF_LAST_PROBLEM_PLUS1): Update to be past DF_MIR
         (DF_MIR_INFO_BB): New macro.
         (DF_MIR_IN, DF_MIR_OUT): New macros.
         (struct df_mir_bb_info): New.
         (df_mir): New macro.
         (df_mir_add_problem, df_mir_simulate_one_insn): New forward
         declarations.
         (df_mir_get_bb_info): New.
         * df-problems.c (struct df_mir_problem_data): New.
         (df_mir_free_bb_info, df_mir_alloc, df_mir_reset,
         df_mir_bb_local_compute, df_mir_local_compute, df_mir_init,
         df_mir_confluence_0, df_mir_confluence_n,
         df_mir_transfer_function, df_mir_free, df_mir_top_dump,
         df_mir_bottom_dump, df_mir_verify_solution_start,
         df_mir_verify_solution_end): New.
         (problem_MIR): New.
         (df_mir_add_problem, df_mir_simulate_one_insn): New.
         * timevar.def (TV_DF_MIR): New.
         * ree.c: Include bitmap.h
         (add_removable_extension): Add an INIT_REGS parameter.  Use it
         to skip zero-extensions that may get an uninitialized register.
         (find_removable_extensions): Compute must-initialized registers
         using the MIR dataflow problem. Update the call to
         add_removable_extension.
         (find_and_remove_re): Call df_mir_add_problem.

gcc/testsuite/ChangeLog:

         * gnat.dg/opt50.adb: New test.
         * gnat.dg/opt50_pkg.adb: New helper.
         * gnat.dg/opt50_pkg.ads: New helper.

[PATCH 2/2] DF_LIVE: make clobbers cancel effect of previous GENs in
  the same BBs

gcc/ChangeLog:

         * df-problems.c (df_live_bb_local_compute): Clear GEN bits for
         DF_REF_MUST_CLOBBER references.

Comments

Bernd Schmidt Oct. 14, 2015, 1:41 p.m. UTC | #1
On 10/13/2015 05:17 PM, Pierre-Marie de Rodat wrote:
> The first attached patch is the second attempt to fix PR
> rtl-optimization/66790 (see
> <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66790>).
>
> The second one is a fix for some inconsistency noticed while working on
> the original bug. This specific patch fixes no known bug, but anyway…
>
> Both were bootstrapped and regtested on x86_64-linux. Ok to commit?
> Thank you in advance!
>
> [PATCH 1/2] REE: fix uninitialized registers handling

This one is OK with minor changes. I ran some tests with it, and the mir 
sets look good this time. Code generation still seems unaffected by it 
on all my example code (which is as expected).

> +
> +  /* Ignoring artificial defs is intentionnal: these often pretend that some

"intentional".

> +      if ((!bitmap_equal_p (&problem_data->in[bb->index], DF_MIR_IN (bb)))
> +	  || (!bitmap_equal_p (&problem_data->out[bb->index], DF_MIR_OUT (bb))))
> +	{
> +	  /*df_dump (stderr);*/
> +	  gcc_unreachable ();
> +	}

Please remove the commented out code and then also the unnecessary 
braces. In general we avoid commented out code in gcc, but when doing 
it, #if 0 is generally a better method.

> +      const rtx reg = XEXP (src, 0);

Drop the const maybe? It doesn't seem to add much and the idiom is to 
just use rtx.

>>From ff694bf70e0b1ebd336c684713ce6153cc26b3d6 Mon Sep 17 00:00:00 2001
> From: Pierre-Marie de Rodat<derodat@adacore.com>
> Date: Tue, 22 Sep 2015 16:02:41 +0200
> Subject: [PATCH 2/2] DF_LIVE: make clobbers cancel effect of previous GENs in
>   the same BBs
>
> gcc/ChangeLog:
>
> 	* df-problems.c (df_live_bb_local_compute): Clear GEN bits for
> 	DF_REF_MUST_CLOBBER references.

This one is probably ok too; I still want to experiment with it a little.


Bernd
Bernd Schmidt Oct. 23, 2015, 11:17 a.m. UTC | #2
On 10/13/2015 05:17 PM, Pierre-Marie de Rodat wrote:
> diff --git a/gcc/df-problems.c b/gcc/df-problems.c
> index c08ae36..56e1cf5 100644
> --- a/gcc/df-problems.c
> +++ b/gcc/df-problems.c
> @@ -1464,9 +1464,12 @@ df_live_bb_local_compute (unsigned int bb_index)
>   	       seen are included in the gen set. */
>   	    bitmap_set_bit (&bb_info->gen, regno);
>   	  else if (DF_REF_FLAGS_IS_SET (def, DF_REF_MUST_CLOBBER))
> -	    /* Only must clobbers for the entire reg destroy the
> -	       value.  */
> -	    bitmap_set_bit (&bb_info->kill, regno);
> +	    {
> +	      /* Only must clobbers for the entire reg destroy the
> +		 value.  */
> +	      bitmap_set_bit (&bb_info->kill, regno);
> +	      bitmap_clear_bit (&bb_info->gen, regno);
> +	    }
>   	  else if (! DF_REF_FLAGS_IS_SET (def, DF_REF_MAY_CLOBBER))
>   	    bitmap_set_bit (&bb_info->gen, regno);
>   	}

I think I haven't approved that yet. It is ok, but I do wonder whether 
there really is a point distinguishing between MUST_CLOBBER and MAY_CLOBBER.


Bernd
diff mbox

Patch

From ff694bf70e0b1ebd336c684713ce6153cc26b3d6 Mon Sep 17 00:00:00 2001
From: Pierre-Marie de Rodat <derodat@adacore.com>
Date: Tue, 22 Sep 2015 16:02:41 +0200
Subject: [PATCH 2/2] DF_LIVE: make clobbers cancel effect of previous GENs in
 the same BBs

gcc/ChangeLog:

	* df-problems.c (df_live_bb_local_compute): Clear GEN bits for
	DF_REF_MUST_CLOBBER references.
---
 gcc/df-problems.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/gcc/df-problems.c b/gcc/df-problems.c
index c08ae36..56e1cf5 100644
--- a/gcc/df-problems.c
+++ b/gcc/df-problems.c
@@ -1464,9 +1464,12 @@  df_live_bb_local_compute (unsigned int bb_index)
 	       seen are included in the gen set. */
 	    bitmap_set_bit (&bb_info->gen, regno);
 	  else if (DF_REF_FLAGS_IS_SET (def, DF_REF_MUST_CLOBBER))
-	    /* Only must clobbers for the entire reg destroy the
-	       value.  */
-	    bitmap_set_bit (&bb_info->kill, regno);
+	    {
+	      /* Only must clobbers for the entire reg destroy the
+		 value.  */
+	      bitmap_set_bit (&bb_info->kill, regno);
+	      bitmap_clear_bit (&bb_info->gen, regno);
+	    }
 	  else if (! DF_REF_FLAGS_IS_SET (def, DF_REF_MAY_CLOBBER))
 	    bitmap_set_bit (&bb_info->gen, regno);
 	}
-- 
2.6.0