This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix gcc.dg/uninit-pred-8_b.c fallout on GCC 8 branch (PR89551)
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 15 Mar 2019 10:22:11 +0100 (CET)
- Subject: [PATCH] Fix gcc.dg/uninit-pred-8_b.c fallout on GCC 8 branch (PR89551)
The following backports support for --param logical-op-non-short-circuit
to the GCC 8 branch (but not all the testsuite adjustments) and adjusts
the gcc.dg/uninit-pred-8_b.c as was done on trunk for the PR89497 fix.
Boostrap / regtest running on x86_64-unknown-linux-gnu.
Richard.
2019-03-15 Richard Biener <rguenther@suse.de>
Backport from mainline
2019-03-06 Richard Biener <rguenther@suse.de>
PR testsuite/89551
* gcc.dg/uninit-pred-8_b.c: Force logical-op-non-short-circuit
the way that makes the testcase PASS.
2018-11-30 Jakub Jelinek <jakub@redhat.com>
PR testsuite/85368
* params.def (PARAM_LOGICAL_OP_NON_SHORT_CIRCUIT): New param.
* tree-ssa-ifcombine.c (ifcombine_ifandif): If
--param logical-op-non-short-circuit is present, override
LOGICAL_OP_NON_SHORT_CIRCUIT value from the param.
* fold-const.c (fold_range_test, fold_truth_andor): Likewise.
Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c (revision 269701)
+++ gcc/fold-const.c (working copy)
@@ -5515,12 +5515,15 @@ fold_range_test (location_t loc, enum tr
/* On machines where the branch cost is expensive, if this is a
short-circuited branch and the underlying object on both sides
is the same, make a non-short-circuit operation. */
- else if (LOGICAL_OP_NON_SHORT_CIRCUIT
- && !flag_sanitize_coverage
- && lhs != 0 && rhs != 0
- && (code == TRUTH_ANDIF_EXPR
- || code == TRUTH_ORIF_EXPR)
- && operand_equal_p (lhs, rhs, 0))
+ bool logical_op_non_short_circuit = LOGICAL_OP_NON_SHORT_CIRCUIT;
+ if (PARAM_VALUE (PARAM_LOGICAL_OP_NON_SHORT_CIRCUIT) != -1)
+ logical_op_non_short_circuit
+ = PARAM_VALUE (PARAM_LOGICAL_OP_NON_SHORT_CIRCUIT);
+ if (logical_op_non_short_circuit
+ && !flag_sanitize_coverage
+ && lhs != 0 && rhs != 0
+ && (code == TRUTH_ANDIF_EXPR || code == TRUTH_ORIF_EXPR)
+ && operand_equal_p (lhs, rhs, 0))
{
/* If simple enough, just rewrite. Otherwise, make a SAVE_EXPR
unless we are at top level or LHS contains a PLACEHOLDER_EXPR, in
@@ -8165,7 +8168,11 @@ fold_truth_andor (location_t loc, enum t
if ((tem = fold_truth_andor_1 (loc, code, type, arg0, arg1)) != 0)
return tem;
- if (LOGICAL_OP_NON_SHORT_CIRCUIT
+ bool logical_op_non_short_circuit = LOGICAL_OP_NON_SHORT_CIRCUIT;
+ if (PARAM_VALUE (PARAM_LOGICAL_OP_NON_SHORT_CIRCUIT) != -1)
+ logical_op_non_short_circuit
+ = PARAM_VALUE (PARAM_LOGICAL_OP_NON_SHORT_CIRCUIT);
+ if (logical_op_non_short_circuit
&& !flag_sanitize_coverage
&& (code == TRUTH_AND_EXPR
|| code == TRUTH_ANDIF_EXPR
Index: gcc/params.def
===================================================================
--- gcc/params.def (revision 269701)
+++ gcc/params.def (working copy)
@@ -1331,6 +1331,11 @@ DEFPARAM(PARAM_AVOID_FMA_MAX_BITS,
"Maximum number of bits for which we avoid creating FMAs.",
0, 0, 512)
+DEFPARAM(PARAM_LOGICAL_OP_NON_SHORT_CIRCUIT,
+ "logical-op-non-short-circuit",
+ "True if a non-short-circuit operation is optimal.",
+ -1, -1, 1)
+
/*
Local variables:
Index: gcc/testsuite/gcc.dg/uninit-pred-8_b.c
===================================================================
--- gcc/testsuite/gcc.dg/uninit-pred-8_b.c (revision 269701)
+++ gcc/testsuite/gcc.dg/uninit-pred-8_b.c (working copy)
@@ -1,6 +1,7 @@
-
/* { dg-do compile } */
-/* { dg-options "-Wuninitialized -O2" } */
+/* ??? Jump threading makes a mess of the logical-op-non-short-circuit=0 case
+ so force it our way. */
+/* { dg-options "-Wuninitialized -O2 --param logical-op-non-short-circuit=1" } */
int g;
void bar();
Index: gcc/tree-ssa-ifcombine.c
===================================================================
--- gcc/tree-ssa-ifcombine.c (revision 269701)
+++ gcc/tree-ssa-ifcombine.c (working copy)
@@ -40,6 +40,7 @@ along with GCC; see the file COPYING3.
#include "gimplify-me.h"
#include "tree-cfg.h"
#include "tree-ssa.h"
+#include "params.h"
#ifndef LOGICAL_OP_NON_SHORT_CIRCUIT
#define LOGICAL_OP_NON_SHORT_CIRCUIT \
@@ -556,7 +557,11 @@ ifcombine_ifandif (basic_block inner_con
{
tree t1, t2;
gimple_stmt_iterator gsi;
- if (!LOGICAL_OP_NON_SHORT_CIRCUIT || flag_sanitize_coverage)
+ bool logical_op_non_short_circuit = LOGICAL_OP_NON_SHORT_CIRCUIT;
+ if (PARAM_VALUE (PARAM_LOGICAL_OP_NON_SHORT_CIRCUIT) != -1)
+ logical_op_non_short_circuit
+ = PARAM_VALUE (PARAM_LOGICAL_OP_NON_SHORT_CIRCUIT);
+ if (!logical_op_non_short_circuit || flag_sanitize_coverage)
return false;
/* Only do this optimization if the inner bb contains only the conditional. */
if (!gsi_one_before_end_p (gsi_start_nondebug_after_labels_bb (inner_cond_bb)))