* tree-ssa-ifcombine.c (update_profile_after_ifcombine): New function.
(ifcombine_ifandif): Use it.
* gcc.dg/tree-ssa/ssa-ifcombine-1.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/ssa-ifcombine-2.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/ssa-ifcombine-3.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/ssa-ifcombine-4.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/ssa-ifcombine-5.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/ssa-ifcombine-6.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/ssa-ifcombine-7.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/ssa-ifcombine-8.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/ssa-ifcombine-9.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/ssa-ifcombine-10.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/ssa-ifcombine-11.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/ssa-ifcombine-12.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/ssa-ifcombine-13.c: Check for no profile mismatches.
From-SVN: r245151
+2017-02-02 Jan Hubicka <hubicka@ucw.cz>
+
+ * tree-ssa-ifcombine.c (update_profile_after_ifcombine): New function.
+ (ifcombine_ifandif): Use it.
+
2017-02-03 Martin Liska <mliska@suse.cz>
* doc/invoke.texi: Document default value for
+2017-02-02 Jan Hubicka <hubicka@ucw.cz>
+
+ * gcc.dg/tree-ssa/ssa-ifcombine-1.c: Check for no profile mismatches.
+ * gcc.dg/tree-ssa/ssa-ifcombine-2.c: Check for no profile mismatches.
+ * gcc.dg/tree-ssa/ssa-ifcombine-3.c: Check for no profile mismatches.
+ * gcc.dg/tree-ssa/ssa-ifcombine-4.c: Check for no profile mismatches.
+ * gcc.dg/tree-ssa/ssa-ifcombine-5.c: Check for no profile mismatches.
+ * gcc.dg/tree-ssa/ssa-ifcombine-6.c: Check for no profile mismatches.
+ * gcc.dg/tree-ssa/ssa-ifcombine-7.c: Check for no profile mismatches.
+ * gcc.dg/tree-ssa/ssa-ifcombine-8.c: Check for no profile mismatches.
+ * gcc.dg/tree-ssa/ssa-ifcombine-9.c: Check for no profile mismatches.
+ * gcc.dg/tree-ssa/ssa-ifcombine-10.c: Check for no profile mismatches.
+ * gcc.dg/tree-ssa/ssa-ifcombine-11.c: Check for no profile mismatches.
+ * gcc.dg/tree-ssa/ssa-ifcombine-12.c: Check for no profile mismatches.
+ * gcc.dg/tree-ssa/ssa-ifcombine-13.c: Check for no profile mismatches.
+
2017-02-02 Martin Sebor <msebor@redhat.com>
PR middle-end/79275
/* { dg-do compile } */
-/* { dg-options "-O -fdump-tree-optimized" } */
+/* { dg-options "-O -fdump-tree-optimized-details-blocks" } */
/* Testcase for PR31657. */
}
/* { dg-final { scan-tree-dump "\\|" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fdump-tree-optimized-details-blocks" } */
/* Testcase for PR31657. */
return t;
}
/* { dg-final { scan-tree-dump "& 5" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */
/* { dg-do compile } */
-/* { dg-options "-O -fdump-tree-optimized" } */
+/* { dg-options "-O -fdump-tree-optimized-details-blocks" } */
/* Testcase for PR31657. */
int g(void);
}
/* { dg-final { scan-tree-dump "& 5" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */
/* { dg-do compile } */
-/* { dg-options "-O2 -fno-tree-vrp -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fno-tree-vrp -fdump-tree-optimized-details-blocks" } */
/* Testcase for PR31657. */
return t;
}
/* { dg-final { scan-tree-dump "& 5" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */
/* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-optimized" } */
+/* { dg-options "-O1 -fdump-tree-optimized-details-blocks" } */
/* { dg-additional-options "-mbranch-cost=2" { target { i?86-*-* x86_64-*-* s390*-*-* avr*-*-* } } } */
_Bool f1(_Bool a, _Bool b)
/* For LOGICAL_OP_NON_SHORT_CIRCUIT, this should be optimized
into return a & b;, with no ifs. */
/* { dg-final { scan-tree-dump-not "if" "optimized" { target { i?86-*-* x86_64-*-* s390*-*-* avr*-*-* } } } } */
+/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */
/* { dg-do compile } */
-/* { dg-options "-O -fdump-tree-optimized" } */
+/* { dg-options "-O -fdump-tree-optimized-details-blocks" } */
/* Testcase for PR31657. */
}
/* { dg-final { scan-tree-dump "\\|" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */
/* { dg-do compile } */
-/* { dg-options "-O -fdump-tree-optimized" } */
+/* { dg-options "-O -fdump-tree-optimized-details-blocks" } */
/* Testcase extracted from PR15353. */
}
/* { dg-final { scan-tree-dump ">=" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */
/* { dg-do compile } */
-/* { dg-options "-O -fdump-tree-optimized" } */
+/* { dg-options "-O -fdump-tree-optimized-details-blocks" } */
/* Testcase extracted from PR15353. */
}
/* { dg-final { scan-tree-dump "!=" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */
/* { dg-do compile } */
-/* { dg-options "-O -fdump-tree-optimized" } */
+/* { dg-options "-O -fdump-tree-optimized-details-blocks" } */
/* Testcase from PR15353. */
}
/* { dg-final { scan-tree-dump ">=" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */
/* { dg-do compile } */
-/* { dg-options "-O -fdump-tree-ifcombine" } */
+/* { dg-options "-O -fdump-tree-ifcombine-details-blocks" } */
void bar (void);
/* { dg-final { scan-tree-dump "optimizing bits or bits test" "ifcombine" } } */
/* { dg-final { scan-tree-dump "optimizing double bit test" "ifcombine" } } */
+/* { dg-final { scan-tree-dump-not "Invalid sum" "ifcombine" } } */
/* { dg-do compile } */
-/* { dg-options "-O -fdump-tree-ifcombine" } */
+/* { dg-options "-O -fdump-tree-ifcombine-details-blocks" } */
int test1 (int i, int j)
{
/* The above should be optimized to a i > j test by ifcombine. */
/* { dg-final { scan-tree-dump " > " "ifcombine" } } */
+/* { dg-final { scan-tree-dump-not "Invalid sum" "ifcombine" } } */
/* { dg-do compile } */
-/* { dg-options "-O -fno-trapping-math -fdump-tree-ifcombine" } */
+/* { dg-options "-O -fno-trapping-math -fdump-tree-ifcombine-details-blocks" } */
double test1 (double i, double j)
{
Instead we get u<=, which is acceptable with -fno-trapping-math. */
/* { dg-final { scan-tree-dump " u<= " "ifcombine" } } */
+/* { dg-final { scan-tree-dump-not "Invalid sum" "ifcombine" } } */
/* { dg-do compile } */
-/* { dg-options "-O2 -fno-trapping-math -fdump-tree-ifcombine" } */
+/* { dg-options "-O2 -fno-trapping-math -fdump-tree-ifcombine-details-blocks" } */
void f ();
enum Sign { NEG=-1, ZERO, POS };
The transformation would also be legal with -ftrapping-math. */
/* { dg-final { scan-tree-dump "optimizing.* < " "ifcombine" } } */
+/* { dg-final { scan-tree-dump-not "Invalid sum" "ifcombine" } } */
return true;
}
+
+/* Update profile after code in outer_cond_bb was adjusted so
+ outer_cond_bb has no condition. */
+
+static void
+update_profile_after_ifcombine (basic_block inner_cond_bb,
+ basic_block outer_cond_bb)
+{
+ edge outer_to_inner = find_edge (outer_cond_bb, inner_cond_bb);
+ edge outer2 = (EDGE_SUCC (outer_cond_bb, 0) == outer_to_inner
+ ? EDGE_SUCC (outer_cond_bb, 1)
+ : EDGE_SUCC (outer_cond_bb, 0));
+ edge inner_taken = EDGE_SUCC (inner_cond_bb, 0);
+ edge inner_not_taken = EDGE_SUCC (inner_cond_bb, 1);
+
+ if (inner_taken->dest != outer2->dest)
+ std::swap (inner_taken, inner_not_taken);
+ gcc_assert (inner_taken->dest == outer2->dest);
+
+ /* In the following we assume that inner_cond_bb has single predecessor. */
+ gcc_assert (single_pred_p (inner_cond_bb));
+
+ /* Path outer_cond_bb->(outer2) needs to be merged into path
+ outer_cond_bb->(outer_to_inner)->inner_cond_bb->(inner_taken)
+ and probability of inner_not_taken updated. */
+
+ outer_to_inner->count = outer_cond_bb->count;
+ inner_cond_bb->count = outer_cond_bb->count;
+ inner_taken->count += outer2->count;
+ outer2->count = 0;
+
+ inner_taken->probability = outer2->probability
+ + RDIV (outer_to_inner->probability
+ * inner_taken->probability,
+ REG_BR_PROB_BASE);
+ if (inner_taken->probability > REG_BR_PROB_BASE)
+ inner_taken->probability = REG_BR_PROB_BASE;
+ inner_not_taken->probability = REG_BR_PROB_BASE
+ - inner_taken->probability;
+
+ outer_to_inner->probability = REG_BR_PROB_BASE;
+ inner_cond_bb->frequency = outer_cond_bb->frequency;
+ outer2->probability = 0;
+}
+
/* If-convert on a and pattern with a common else block. The inner
if is specified by its INNER_COND_BB, the outer by OUTER_COND_BB.
inner_inv, outer_inv and result_inv indicate whether the conditions
outer_inv ? boolean_false_node : boolean_true_node);
update_stmt (outer_cond);
+ update_profile_after_ifcombine (inner_cond_bb, outer_cond_bb);
+
if (dump_file)
{
fprintf (dump_file, "optimizing double bit test to ");
gimple_cond_set_condition_from_tree (outer_cond,
outer_inv ? boolean_false_node : boolean_true_node);
update_stmt (outer_cond);
+ update_profile_after_ifcombine (inner_cond_bb, outer_cond_bb);
if (dump_file)
{
gimple_cond_set_condition_from_tree (outer_cond,
outer_inv ? boolean_false_node : boolean_true_node);
update_stmt (outer_cond);
+ update_profile_after_ifcombine (inner_cond_bb, outer_cond_bb);
if (dump_file)
{