On 08/02/2017 06:29 PM, Jakub Jelinek wrote:
On Wed, Aug 02, 2017 at 06:15:31PM +0200, Tom de Vries wrote:
2017-08-02  Tom de Vries<t...@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.


Updated with likely/unlikely split.

OK?

Thanks,
- Tom
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, and set the split to unlikely/likely:
  if (_5 == 0)
    goto <bb 6>; [19.99%] [count: INV]
  else
    goto <bb 2>; [80.01%] [count: INV]

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

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

---
 gcc/omp-simd-clone.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c
index a1a563e..fbb122c 100644
--- a/gcc/omp-simd-clone.c
+++ b/gcc/omp-simd-clone.c
@@ -1240,8 +1240,11 @@ 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);
-      FALLTHRU_EDGE (loop->header)->flags = EDGE_FALSE_VALUE;
+      edge e = make_edge (loop->header, incr_bb, EDGE_TRUE_VALUE);
+      e->probability = profile_probability::unlikely ().guessed ();
+      edge fallthru = FALLTHRU_EDGE (loop->header);
+      fallthru->flags = EDGE_FALSE_VALUE;
+      fallthru->probability = profile_probability::likely ().guessed ();
     }
 
   basic_block latch_bb = NULL;

Reply via email to