diff mbox

Add missing edge probability in simd_clone_adjust

Message ID 4639e236-9c4a-ef5c-ade5-b955011e772b@mentor.com
State New
Headers show

Commit Message

Tom de Vries Aug. 2, 2017, 4:15 p.m. UTC
[ Re: [PATCH] Verify edge probability consistency in verify_flow_info ]

On 08/02/2017 06:07 PM, Tom de Vries wrote:
> I've written this patch to check for the missing probability more 
> consistently. I'm not certain if we can require that the probability 
> should always be set, so I'm just requiring that if it is set on one 
> outgoing edge, it needs to be set on all outgoing edges.
> 
> Sofar I've build a c-only x86_64 non-bootstrap compiler and ran dg.exp. 
> The only problem I ran into was in attr-simd{,-2,-4}.c. I've written a 
> tentative patch for that, and will submit it as follow-up.

Jakub,

this patch adds a missing edge probability in simd_clone_adjust.

OK for trunk if bootstrap and reg-test on x86_64 succeeds?

Thanks,
- Tom

Comments

Jakub Jelinek Aug. 2, 2017, 4:29 p.m. UTC | #1
On Wed, Aug 02, 2017 at 06:15:31PM +0200, Tom de Vries wrote:
> 2017-08-02  Tom de Vries  <tom@codesourcery.com>
> 
> 	* omp-simd-clone.c (simd_clone_adjust): Add missing edge probability.

I think that is not the right probability, when using masked simd, the point
is that it is called from conditional code where usually not all the bits in
the mask are set.  So I think it is better to use say likely () probability
for the EDGE_FALSE_VALUE edge (that mask != 0) and unlikely () probability
for the EDGE_TRUE_VALUE edge.
Hopefully that conditional goes away later when vectorized, but if it
doesn't, we shouldn't  say it is that unlikely it will be masked off.

> diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c
> index a1a563e..5b5d199 100644
> --- a/gcc/omp-simd-clone.c
> +++ b/gcc/omp-simd-clone.c
> @@ -1240,7 +1240,8 @@ simd_clone_adjust (struct cgraph_node *node)
>        g = gimple_build_cond (EQ_EXPR, mask, build_zero_cst (TREE_TYPE (mask)),
>  			     NULL, NULL);
>        gsi_insert_after (&gsi, g, GSI_CONTINUE_LINKING);
> -      make_edge (loop->header, incr_bb, EDGE_TRUE_VALUE);
> +      edge e = make_edge (loop->header, incr_bb, EDGE_TRUE_VALUE);
> +      e->probability = profile_probability::guessed_never ();
>        FALLTHRU_EDGE (loop->header)->flags = EDGE_FALSE_VALUE;
>      }
>  


	Jakub
diff mbox

Patch

Add missing edge probability in simd_clone_adjust

Currently we generate an if with probability set on only one of the two edges:
  <bb 5> [0.00%] [count: INV]:
  _5 = mask.3[iter.6_3];
  if (_5 == 0)
    goto <bb 6>; [INV] [count: INV]
  else
    goto <bb 2>; [100.00%] [count: INV]

Add the missing edge probability:
    goto <bb 6>; [0.00%] [count: INV]

2017-08-02  Tom de Vries  <tom@codesourcery.com>

	* omp-simd-clone.c (simd_clone_adjust): Add missing edge probability.

---
 gcc/omp-simd-clone.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c
index a1a563e..5b5d199 100644
--- a/gcc/omp-simd-clone.c
+++ b/gcc/omp-simd-clone.c
@@ -1240,7 +1240,8 @@  simd_clone_adjust (struct cgraph_node *node)
       g = gimple_build_cond (EQ_EXPR, mask, build_zero_cst (TREE_TYPE (mask)),
 			     NULL, NULL);
       gsi_insert_after (&gsi, g, GSI_CONTINUE_LINKING);
-      make_edge (loop->header, incr_bb, EDGE_TRUE_VALUE);
+      edge e = make_edge (loop->header, incr_bb, EDGE_TRUE_VALUE);
+      e->probability = profile_probability::guessed_never ();
       FALLTHRU_EDGE (loop->header)->flags = EDGE_FALSE_VALUE;
     }