]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/79347 (vect_do_peeling is messing up profile)
authorJan Hubicka <hubicka@ucw.cz>
Sun, 5 Feb 2017 17:16:52 +0000 (18:16 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sun, 5 Feb 2017 17:16:52 +0000 (17:16 +0000)
PR tree-ssa/79347
* cfgloopmanip.c (lv_adjust_loop_entry_edge, loop_version): Add
ELSE_PROB.
* cfgloopmanip.h (loop_version): Update prototype.
* modulo-sched.c (sms_schedule): Update call of loop_version.
* tree-if-conv.c(version_loop_for_if_conversion): Likewise.
* tree-parloops.c (gen_parallel_loop): Likewise.
* tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Likewise.
* tree-ssa-loop-split.c (split_loop): Likewise.
* tree-ssa-loop-unswitch.c (tree_unswitch_loop): Likewise.
* tree-vect-loop-manip.c (vect_loop_versioning): Likewise.

* gcc.dg/tree-ssa/ifc-10.c: Match for profile mismatches.
* gcc.dg/tree-ssa/ifc-11.c: Match for profile mismatches.
* gcc.dg/tree-ssa/ifc-12.c: Match for profile mismatches.
* gcc.dg/tree-ssa/ifc-20040816-1.c: Match for profile mismatches.
* gcc.dg/tree-ssa/ifc-20040816-2.c: Match for profile mismatches.
* gcc.dg/tree-ssa/ifc-5.c: Match for profile mismatches.
* gcc.dg/tree-ssa/ifc-8.c: Match for profile mismatches.
* gcc.dg/tree-ssa/ifc-9.c: Match for profile mismatches.
* gcc.dg/tree-ssa/ifc-cd.c: Match for profile mismatches.
* gcc.dg/tree-ssa/ifc-pr56541.c: Match for profile mismatches.
* gcc.dg/tree-ssa/ifc-pr68583.c: Match for profile mismatches.
* gcc.dg/tree-ssa/ifc-pr69489-1.c: Match for profile mismatches.
* gcc.dg/tree-ssa/ifc-pr69489-2.c: Match for profile mismatches.

From-SVN: r245196

24 files changed:
gcc/ChangeLog
gcc/cfgloopmanip.c
gcc/cfgloopmanip.h
gcc/modulo-sched.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ifc-10.c
gcc/testsuite/gcc.dg/tree-ssa/ifc-11.c
gcc/testsuite/gcc.dg/tree-ssa/ifc-12.c
gcc/testsuite/gcc.dg/tree-ssa/ifc-20040816-1.c
gcc/testsuite/gcc.dg/tree-ssa/ifc-20040816-2.c
gcc/testsuite/gcc.dg/tree-ssa/ifc-5.c
gcc/testsuite/gcc.dg/tree-ssa/ifc-8.c
gcc/testsuite/gcc.dg/tree-ssa/ifc-9.c
gcc/testsuite/gcc.dg/tree-ssa/ifc-cd.c
gcc/testsuite/gcc.dg/tree-ssa/ifc-pr56541.c
gcc/testsuite/gcc.dg/tree-ssa/ifc-pr68583.c
gcc/testsuite/gcc.dg/tree-ssa/ifc-pr69489-1.c
gcc/testsuite/gcc.dg/tree-ssa/ifc-pr69489-2.c
gcc/tree-if-conv.c
gcc/tree-parloops.c
gcc/tree-ssa-loop-manip.c
gcc/tree-ssa-loop-split.c
gcc/tree-ssa-loop-unswitch.c
gcc/tree-vect-loop-manip.c

index 22a8102f2991b90a31284bc21421b1444d242413..a8c6be100e2ec74c72a9d2c098f6573e924c2859 100644 (file)
@@ -1,3 +1,17 @@
+2017-02-05  Jan Hubicka  <hubicka@ucw.cz>
+
+       PR tree-ssa/79347
+       * cfgloopmanip.c (lv_adjust_loop_entry_edge, loop_version): Add
+       ELSE_PROB.
+       * cfgloopmanip.h (loop_version): Update prototype.
+       * modulo-sched.c (sms_schedule): Update call of loop_version.
+       * tree-if-conv.c(version_loop_for_if_conversion): Likewise.
+       * tree-parloops.c (gen_parallel_loop): Likewise.
+       * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Likewise.
+       * tree-ssa-loop-split.c (split_loop): Likewise.
+       * tree-ssa-loop-unswitch.c (tree_unswitch_loop): Likewise.
+       * tree-vect-loop-manip.c (vect_loop_versioning): Likewise.
+
 2017-02-05  Martin Liska  <mliska@suse.cz>
 
        PR bootstrap/78985
index 71fbe6b56e49377fb422005068ace9f6112791d6..a0e3e30720e2373ca16edc450a53192c1e779e32 100644 (file)
@@ -1645,11 +1645,14 @@ force_single_succ_latches (void)
                        |
                        +---------> [second_head]
 
-  THEN_PROB is the probability of then branch of the condition.  */
+  THEN_PROB is the probability of then branch of the condition.
+  ELSE_PROB is the probability of else branch. Note that they may be both
+  REG_BR_PROB_BASE when condition is IFN_LOOP_VECTORIZED.  */
 
 static basic_block
 lv_adjust_loop_entry_edge (basic_block first_head, basic_block second_head,
-                          edge e, void *cond_expr, unsigned then_prob)
+                          edge e, void *cond_expr, unsigned then_prob,
+                          unsigned else_prob)
 {
   basic_block new_head = NULL;
   edge e1;
@@ -1668,7 +1671,7 @@ lv_adjust_loop_entry_edge (basic_block first_head, basic_block second_head,
   e1 = make_edge (new_head, first_head,
                  current_ir_type () == IR_GIMPLE ? EDGE_TRUE_VALUE : 0);
   e1->probability = then_prob;
-  e->probability = REG_BR_PROB_BASE - then_prob;
+  e->probability = else_prob;
   e1->count = apply_probability (e->count, e1->probability);
   e->count = apply_probability (e->count, e->probability);
 
@@ -1701,7 +1704,8 @@ lv_adjust_loop_entry_edge (basic_block first_head, basic_block second_head,
 struct loop *
 loop_version (struct loop *loop,
              void *cond_expr, basic_block *condition_bb,
-             unsigned then_prob, unsigned then_scale, unsigned else_scale,
+             unsigned then_prob, unsigned else_prob,
+             unsigned then_scale, unsigned else_scale,
              bool place_after)
 {
   basic_block first_head, second_head;
@@ -1732,7 +1736,7 @@ loop_version (struct loop *loop,
 
   /* Split loop entry edge and insert new block with cond expr.  */
   cond_bb =  lv_adjust_loop_entry_edge (first_head, second_head,
-                                       entry, cond_expr, then_prob);
+                                       entry, cond_expr, then_prob, else_prob);
   if (condition_bb)
     *condition_bb = cond_bb;
 
index 004becfccb1db6f403ac049cc9203bd29bd78efe..7ad3bf5d7d4d6e154791ad270ab86503e7fe0f6e 100644 (file)
@@ -58,6 +58,7 @@ basic_block create_preheader (struct loop *, int);
 extern void create_preheaders (int);
 extern void force_single_succ_latches (void);
 struct loop * loop_version (struct loop *, void *,
-                           basic_block *, unsigned, unsigned, unsigned, bool);
+                           basic_block *, unsigned, unsigned,
+                           unsigned, unsigned, bool);
 
 #endif /* GCC_CFGLOOPMANIP_H */
index 619ea04c2e78252e123fca189c9891d58692275c..270adc5a2008bf9ea3579681d571f4aad1c3635f 100644 (file)
@@ -1713,7 +1713,8 @@ sms_schedule (void)
                               * REG_BR_PROB_BASE) / 100;
 
              loop_version (loop, comp_rtx, &condition_bb,
-                           prob, prob, REG_BR_PROB_BASE - prob,
+                           prob, REG_BR_PROB_BASE - prob,
+                           prob, REG_BR_PROB_BASE - prob,
                            true);
             }
 
index 898f55a44a3dec9f0d28953b97ee788e736d699b..3214eef3bda15cfa4463b6674a4eb80798f33f32 100644 (file)
@@ -1,3 +1,20 @@
+2017-02-05  Jan Hubicka  <hubicka@ucw.cz>
+
+       PR tree-ssa/79347
+       * gcc.dg/tree-ssa/ifc-10.c: Match for profile mismatches.
+       * gcc.dg/tree-ssa/ifc-11.c: Match for profile mismatches.
+       * gcc.dg/tree-ssa/ifc-12.c: Match for profile mismatches.
+       * gcc.dg/tree-ssa/ifc-20040816-1.c: Match for profile mismatches.
+       * gcc.dg/tree-ssa/ifc-20040816-2.c: Match for profile mismatches.
+       * gcc.dg/tree-ssa/ifc-5.c: Match for profile mismatches.
+       * gcc.dg/tree-ssa/ifc-8.c: Match for profile mismatches.
+       * gcc.dg/tree-ssa/ifc-9.c: Match for profile mismatches.
+       * gcc.dg/tree-ssa/ifc-cd.c: Match for profile mismatches.
+       * gcc.dg/tree-ssa/ifc-pr56541.c: Match for profile mismatches.
+       * gcc.dg/tree-ssa/ifc-pr68583.c: Match for profile mismatches.
+       * gcc.dg/tree-ssa/ifc-pr69489-1.c: Match for profile mismatches.
+       * gcc.dg/tree-ssa/ifc-pr69489-2.c: Match for profile mismatches.
+
 2017-02-05  Andre Vehreschild  <vehre@gcc.gnu.org>
 
        PR fortran/79344
index fbac009944606dbad8ed6911c30666940318a36f..4097145eba680eafc9038bbacdae8d1f38106387 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-Ofast -fno-split-loops -fdump-tree-ifcvt-stats" } */
+/* { dg-options "-Ofast -fno-split-loops -fdump-tree-ifcvt-stats-blocks-details" } */
 /* { dg-require-visibility "" } */
 
 int b[256] = {0}, y;
@@ -20,3 +20,11 @@ int foo (int x, int n)
 }
 
 /* { dg-final { scan-tree-dump-times "Applying if-conversion" 1 "ifcvt" } } */
+
+/* We insert into code
+   if (LOOP_VECTORIZED (...))
+   which is folded by vectorizer.  Both outgoing edges must have probability
+   100% so the resulting profile match after folding.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of outgoing probabilities 200.0" 1 "ifcvt" } } */
+/* { dg-final { scan-tree-dump-times "Invalid sum of incoming frequencies" 1 "ifcvt" } } */
+
index bacf428ec03dcd65f9ba9927945714f06b794f59..a0333fbb28c1a174fcc79b9e55561317e2fb096d 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-Ofast -fdump-tree-ifcvt-stats" } */
+/* { dg-options "-Ofast -fdump-tree-ifcvt-stats-blocks-details" } */
 /* { dg-require-visibility "" } */
 
 int a[1024] = {0.0};
@@ -18,3 +18,11 @@ int foo (float *x)
 }
 
 /* { dg-final { scan-tree-dump-times "Applying if-conversion" 1 "ifcvt" } } */
+
+/* We insert into code
+   if (LOOP_VECTORIZED (...))
+   which is folded by vectorizer.  Both outgoing edges must have probability
+   100% so the resulting profile match after folding.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of outgoing probabilities 200.0" 1 "ifcvt" } } */
+/* Sum is wrong here, but not enough for error to be reported.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of incoming frequencies" 0 "ifcvt" } } */
index 89d42b4d6fd0add66e53d35742aee8778a266cca..535c1f0eb6cc63642ceea9b1d86a651a0c6c8e13 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-Ofast -fdump-tree-ifcvt-stats" } */
+/* { dg-options "-Ofast -fdump-tree-ifcvt-stats-blocks-details" } */
 /* { dg-require-visibility "" } */
 
 struct st
@@ -23,3 +23,12 @@ int foo (int x)
   return 0;
 }
 /* { dg-final { scan-tree-dump-times "Applying if-conversion" 1 "ifcvt" } } */
+
+/* We insert into code
+   if (LOOP_VECTORIZED (...))
+   which is folded by vectorizer.  Both outgoing edges must have probability
+   100% so the resulting profile match after folding.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of outgoing probabilities 200.0" 1 "ifcvt" } } */
+/* Sum is wrong here, but not enough for error to be reported.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of incoming frequencies" 0 "ifcvt" } } */
+
index 7a8e7a5a796563803dca9022f387f715a6c56a81..8badc762267392cd64e49cd0cd3a854f11ecd413 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-c -O2 -ftree-vectorize -fdump-tree-ifcvt-stats" { target *-*-* } } */
+/* { dg-options "-c -O2 -ftree-vectorize -fdump-tree-ifcvt-stats-blocks-details" { target *-*-* } } */
 
 #include <stdarg.h>
 
@@ -33,3 +33,10 @@ int main1 ()
 
 
 /* { dg-final { scan-tree-dump-times "Applying if-conversion" 1 "ifcvt" } } */
+
+/* We insert into code
+   if (LOOP_VECTORIZED (...))
+   which is folded by vectorizer.  Both outgoing edges must have probability
+   100% so the resulting profile match after folding.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of outgoing probabilities 200.0" 1 "ifcvt" } } */
+/* { dg-final { scan-tree-dump-times "Invalid sum of incoming frequencies" 1 "ifcvt" } } */
index b084e7b10a87090e72da1bf413b907c76dcc58c6..a517f6552e6d43f190a45e5d55070525a88478b2 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-c -O2 -ftree-vectorize -fdump-tree-ifcvt-stats" { target *-*-* } } */
+/* { dg-options "-c -O2 -ftree-vectorize -fdump-tree-ifcvt-stats-blocks-details" { target *-*-* } } */
 
 void foo(const int * __restrict__ zr_in,
                const int * __restrict__ zi_in,
@@ -37,3 +37,11 @@ void foo(const int * __restrict__ zr_in,
 
 
 /* { dg-final { scan-tree-dump-times "Applying if-conversion" 1 "ifcvt" } } */
+
+/* We insert into code
+   if (LOOP_VECTORIZED (...))
+   which is folded by vectorizer.  Both outgoing edges must have probability
+   100% so the resulting profile match after folding.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of outgoing probabilities 200.0" 1 "ifcvt" } } */
+/* Sum is wrong here, but not enough for error to be reported.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of incoming frequencies" 0 "ifcvt" } } */
index 875d2d3541fcefe44adda5edc8668b5cc1d3f556..58260dd878b5233db126c44f689cfb02a9956a94 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-c -O2 -ftree-vectorize -fdump-tree-ifcvt-stats" { target *-*-* } } */
+/* { dg-options "-c -O2 -ftree-vectorize -fdump-tree-ifcvt-stats-blocks-details" { target *-*-* } } */
 
 void
 dct_unquantize_h263_inter_c (short *block, int n, int qscale, int nCoeffs)
@@ -21,3 +21,10 @@ dct_unquantize_h263_inter_c (short *block, int n, int qscale, int nCoeffs)
 }
 
 /* { dg-final { scan-tree-dump-times "Applying if-conversion" 1 "ifcvt" } } */
+
+/* We insert into code
+   if (LOOP_VECTORIZED (...))
+   which is folded by vectorizer.  Both outgoing edges must have probability
+   100% so the resulting profile match after folding.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of outgoing probabilities 200.0" 1 "ifcvt" } } */
+/* { dg-final { scan-tree-dump-times "Invalid sum of incoming frequencies" 1 "ifcvt" } } */
index 81a4075cc2915117818c60e954423cae2540d719..6c26c209212898e63a7cfc01d932284a5574a8b5 100644 (file)
@@ -1,6 +1,6 @@
 
 /* { dg-do compile } */
-/* { dg-options "-Ofast -fdump-tree-ifcvt-details -ftree-loop-if-convert-stores" } */
+/* { dg-options "-Ofast -fdump-tree-ifcvt-details-blocks -ftree-loop-if-convert-stores" } */
 /* { dg-require-visibility "" } */
 
 #define LEN 4096
@@ -16,3 +16,11 @@ void test ()
 }
 
 /* { dg-final { scan-tree-dump-times "Applying if-conversion" 1 "ifcvt" } } */
+
+/* We insert into code
+   if (LOOP_VECTORIZED (...))
+   which is folded by vectorizer.  Both outgoing edges must have probability
+   100% so the resulting profile match after folding.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of outgoing probabilities 200.0" 1 "ifcvt" } } */
+/* Sum is wrong here, but not enough for error to be reported.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of incoming frequencies" 0 "ifcvt" } } */
index 338ea2545d24822f8706247bea66b56d334e1f7c..789cb6ae23a0f0f84b12b4cba7389e98da5af9e6 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-Ofast -fno-split-loops -fdump-tree-ifcvt-stats" } */
+/* { dg-options "-Ofast -fno-split-loops -fdump-tree-ifcvt-stats-blocks-details" } */
 /* { dg-require-visibility "" } */
 
 extern int b[256], y;
@@ -20,3 +20,10 @@ int foo (int x, int n)
 }
 
 /* { dg-final { scan-tree-dump-times "Applying if-conversion" 1 "ifcvt" } } */
+
+/* We insert into code
+   if (LOOP_VECTORIZED (...))
+   which is folded by vectorizer.  Both outgoing edges must have probability
+   100% so the resulting profile match after folding.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of outgoing probabilities 200.0" 1 "ifcvt" } } */
+/* { dg-final { scan-tree-dump-times "Invalid sum of incoming frequencies" 1 "ifcvt" } } */
index 29e2559e42be49b42cc20a4e7086127f7031d503..11e142af321d9688df2af35db88660a67ed85e63 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O3 -fdump-tree-ifcvt-details -ftree-loop-if-convert-stores" } */
+/* { dg-options "-O3 -fdump-tree-ifcvt-details-blocks-details -ftree-loop-if-convert-stores" } */
 
 void foo (int *x1, int *x2, int *x3, int *x4, int *y)
 {
@@ -26,3 +26,11 @@ void foo (int *x1, int *x2, int *x3, int *x4, int *y)
 }
 
 /* { dg-final { scan-tree-dump-times "Use predicate of bb" 4 "ifcvt" } } */
+
+/* We insert into code
+   if (LOOP_VECTORIZED (...))
+   which is folded by vectorizer.  Both outgoing edges must have probability
+   100% so the resulting profile match after folding.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of outgoing probabilities 200.0" 1 "ifcvt" } } */
+/* Sum is wrong here, but not enough for error to be reported.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of incoming frequencies" 0 "ifcvt" } } */
index a52bacacedfa81f555da7932c03137279b45372c..9682fbc15df8f36aca5a6a689cfbed1b04f33420 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O3 -fdump-tree-ifcvt-stats" } */
+/* { dg-options "-O3 -fdump-tree-ifcvt-stats-blocks-details" } */
 
 float a,b,c,d;
 
@@ -23,3 +23,11 @@ void foo()
 }
 
 /* { dg-final { scan-tree-dump-times "Applying if-conversion" 1 "ifcvt" } } */
+
+/* We insert into code
+   if (LOOP_VECTORIZED (...))
+   which is folded by vectorizer.  Both outgoing edges must have probability
+   100% so the resulting profile match after folding.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of outgoing probabilities 200.0" 1 "ifcvt" } } */
+/* Sum is wrong here, but not enough for error to be reported.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of incoming frequencies" 0 "ifcvt" } } */
index be89e0855c34713c34b3691f61899f24eec6345d..b128deb4a21b46e47d9229f040bcdea48ed9f6d2 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O3 -fdump-tree-ifcvt" } */
+/* { dg-options "-O3 -fdump-tree-ifcvt-blocks-details" } */
 
 void foo (long *a)
 {
@@ -21,3 +21,10 @@ void foo (long *a)
 }
 
 /* { dg-final { scan-tree-dump "Applying if-conversion" "ifcvt" } } */
+/* We insert into code
+   if (LOOP_VECTORIZED (...))
+   which is folded by vectorizer.  Both outgoing edges must have probability
+   100% so the resulting profile match after folding.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of outgoing probabilities 200.0" 1 "ifcvt" } } */
+/* { dg-final { scan-tree-dump-times "Invalid sum of incoming frequencies" 1 "ifcvt" } } */
+
index 4131afcbdff099b455f865e13650fbae1d5700dc..3ba7de5e6a5d42fda54e97b7f743b9e0aed81586 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -ftree-vectorize -fdump-tree-ifcvt-stats" { target *-*-* } } */
+/* { dg-options "-O2 -ftree-vectorize -fdump-tree-ifcvt-stats-blocks-details" { target *-*-* } } */
 
 void foo (int a[], int b[])
 {
@@ -14,3 +14,11 @@ void foo (int a[], int b[])
 }
 
 /* { dg-final { scan-tree-dump-times "Applying if-conversion" 1 "ifcvt" } } */
+
+/* We insert into code
+   if (LOOP_VECTORIZED (...))
+   which is folded by vectorizer.  Both outgoing edges must have probability
+   100% so the resulting profile match after folding.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of outgoing probabilities 200.0" 1 "ifcvt" } } */
+/* Sum is wrong here, but not enough for error to be reported.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of incoming frequencies" 0 "ifcvt" } } */
index 6661f1a6c1bdc6325a6685cf5ac3626e36e7408a..07589fd7928242e11d8664b6820af8e9b55dc363 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-S -O2 -ftree-vectorize -fdump-tree-ifcvt-stats" { target *-*-* } } */
+/* { dg-options "-S -O2 -ftree-vectorize -fdump-tree-ifcvt-stats-blocks-details" { target *-*-* } } */
 
 double
 foo (const char *u, const char *v, long n)
@@ -15,3 +15,10 @@ foo (const char *u, const char *v, long n)
 }
 
 /* { dg-final { scan-tree-dump-times "Applying if-conversion" 1 "ifcvt" } } */
+
+/* We insert into code
+   if (LOOP_VECTORIZED (...))
+   which is folded by vectorizer.  Both outgoing edges must have probability
+   100% so the resulting profile match after folding.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum of outgoing probabilities 200.0" 1 "ifcvt" } } */
+/* { dg-final { scan-tree-dump-times "Invalid sum of incoming frequencies" 1 "ifcvt" } } */
index c12987e55de3c53fbacc1eb4dbacfdf7a1607784..eb637952e22d504f6fe4e166163c1b76b3488bcc 100644 (file)
@@ -2533,7 +2533,11 @@ combine_blocks (struct loop *loop)
    will be if-converted, the new copy of the loop will not,
    and the LOOP_VECTORIZED internal call will be guarding which
    loop to execute.  The vectorizer pass will fold this
-   internal call into either true or false.  */
+   internal call into either true or false. 
+
+   Note that this function intentionally invalidates profile.  Both edges
+   out of LOOP_VECTORIZED must have 100% probability so the profile remains
+   consistent after the condition is folded in the vectorizer.  */
 
 static struct loop *
 version_loop_for_if_conversion (struct loop *loop)
@@ -2557,9 +2561,11 @@ version_loop_for_if_conversion (struct loop *loop)
     saved_preds[i] = ifc_bbs[i]->aux;
 
   initialize_original_copy_tables ();
+  /* At this point we invalidate porfile confistency until IFN_LOOP_VECTORIZED
+     is re-merged in the vectorizer.  */
   new_loop = loop_version (loop, cond, &cond_bb,
                           REG_BR_PROB_BASE, REG_BR_PROB_BASE,
-                          REG_BR_PROB_BASE, true);
+                          REG_BR_PROB_BASE, REG_BR_PROB_BASE, true);
   free_original_copy_tables ();
 
   for (unsigned i = 0; i < save_length; i++)
index 83aa8308deff28601b6a1fd77b26e7325d765acc..739301140f0a9db04ae3d61af0eb48d4e39bb5e4 100644 (file)
@@ -2353,7 +2353,8 @@ gen_parallel_loop (struct loop *loop,
       /* We assume that the loop usually iterates a lot.  */
       prob = 4 * REG_BR_PROB_BASE / 5;
       loop_version (loop, many_iterations_cond, NULL,
-                   prob, prob, REG_BR_PROB_BASE - prob, true);
+                   prob, REG_BR_PROB_BASE - prob,
+                   prob, REG_BR_PROB_BASE - prob, true);
       update_ssa (TODO_update_ssa);
       free_original_copy_tables ();
     }
index 39fb48454ae769e3557c2642fbef41ea4f155152..43df29c5415aa4f11be80ec71fdd052a318ccc66 100644 (file)
@@ -1202,7 +1202,8 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
   scale_rest = REG_BR_PROB_BASE;
 
   new_loop = loop_version (loop, enter_main_cond, NULL,
-                          prob_entry, scale_unrolled, scale_rest, true);
+                          prob_entry, REG_BR_PROB_BASE - prob_entry,
+                          scale_unrolled, scale_rest, true);
   gcc_assert (new_loop != NULL);
   update_ssa (TODO_update_ssa);
 
index f104b2621c035ea3a661b29ce5fa7e0f1bf5ca1f..39bffc4ef17e44786745f48702bb34bce9caa2e6 100644 (file)
@@ -562,7 +562,8 @@ split_loop (struct loop *loop1, struct tree_niter_desc *niter)
        basic_block cond_bb;
        struct loop *loop2 = loop_version (loop1, cond, &cond_bb,
                                           REG_BR_PROB_BASE, REG_BR_PROB_BASE,
-                                          REG_BR_PROB_BASE, true);
+                                          REG_BR_PROB_BASE, REG_BR_PROB_BASE,
+                                          true);
        gcc_assert (loop2);
        update_ssa (TODO_update_ssa);
 
index 4ef3a6bf80ada3659e7a0af6851cc0fb621d71b8..1d0305a2a8bfec119e6a51ad9631363d00fcd1ba 100644 (file)
@@ -493,7 +493,7 @@ tree_unswitch_loop (struct loop *loop,
   extract_true_false_edges_from_block (unswitch_on, &edge_true, &edge_false);
   prob_true = edge_true->probability;
   return loop_version (loop, unshare_expr (cond),
-                      NULL, prob_true, prob_true,
+                      NULL, prob_true, REG_BR_PROB_BASE - prob_true, prob_true,
                       REG_BR_PROB_BASE - prob_true, false);
 }
 
index 935cd75e554ccf64e4f9b613163eeff29f8ba29b..f29449c37fdfc272dd2a8ab3ff027d0b229f0b73 100644 (file)
@@ -2319,7 +2319,8 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
 
       /* We don't want to scale SCALAR_LOOP's frequencies, we need to
         scale LOOP's frequencies instead.  */
-      nloop = loop_version (scalar_loop, cond_expr, &condition_bb, prob,
+      nloop = loop_version (scalar_loop, cond_expr, &condition_bb,
+                           prob, REG_BR_PROB_BASE - prob,
                            REG_BR_PROB_BASE, REG_BR_PROB_BASE - prob, true);
       scale_loop_frequencies (loop, prob, REG_BR_PROB_BASE);
       /* CONDITION_BB was created above SCALAR_LOOP's preheader,
@@ -2348,7 +2349,8 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
     }
   else
     nloop = loop_version (loop, cond_expr, &condition_bb,
-                         prob, prob, REG_BR_PROB_BASE - prob, true);
+                         prob, REG_BR_PROB_BASE - prob,
+                         prob, REG_BR_PROB_BASE - prob, true);
 
   if (version_niter)
     {