re PR testsuite/85368 (phi-opt-11 test fails on IBM Z)
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Nov 2018 23:26:41 +0000 (00:26 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Nov 2018 23:26:41 +0000 (00:26 +0100)
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.

* lib/target-supports.exp (logical_op_short_circuit): Remove.
* gcc.dg/builtin-bswap-7.c: Remove logical_op_short_circuit
effective target, drop -mbranch-cost= options from the test and
instead pass --param logical-op-non-short-circuit=0 or
--param logical-op-non-short-circuit=1 depending on what the
tests meant to test.
* gcc.dg/pr21643.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-ccmp-2.c: Likewise.
* gcc.dg/tree-ssa/phi-opt-11.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-ccmp-1.c: Likewise.
* gcc.dg/tree-ssa/ssa-dom-thread-4.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-ccmp-3.c: Likewise.
* gcc.dg/tree-ssa/ssa-thread-14.c: Likewise.
* gcc.dg/tree-ssa/vrp47.c: Likewise.
* gcc.dg/tree-ssa/ssa-dom-thread-11.c: Likewise.
* gcc.dg/tree-ssa/ssa-dom-thread-16.c: Likewise.
* gcc.dg/tree-ssa/ssa-dom-thread-14.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-ccmp-5.c: Likewise.
* gcc.dg/tree-ssa/vrp87.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-ccmp-6.c: Likewise.
* gcc.dg/tree-ssa/phi-opt-2.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-13.c: Likewise.
* gcc.dg/tree-ssa/ssa-thread-11.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-ccmp-4.c: Likewise.
* gcc.dg/tree-ssa/forwprop-28.c: Likewise.
* gcc.dg/binop-xor1.c: Likewise.
* gcc.dg/pr46309.c: Likewise.
* gcc.dg/tree-ssa/ssa-dom-thread-18.c: New test.
* gcc.dg/tree-ssa/reassoc-32.c: Add
--param logical-op-non-short-circuit=1 to dg-options.
* gcc.dg/tree-ssa/reassoc-33.c: Likewise.
* gcc.dg/tree-ssa/reassoc-34.c: Likewise.
* gcc.dg/tree-ssa/reassoc-35.c: Likewise.
* gcc.dg/tree-ssa/reassoc-36.c: Likewise.

From-SVN: r266700

34 files changed:
gcc/ChangeLog
gcc/fold-const.c
gcc/params.def
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/binop-xor1.c
gcc/testsuite/gcc.dg/builtin-bswap-7.c
gcc/testsuite/gcc.dg/pr21643.c
gcc/testsuite/gcc.dg/pr46309.c
gcc/testsuite/gcc.dg/tree-ssa/forwprop-28.c
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-11.c
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-2.c
gcc/testsuite/gcc.dg/tree-ssa/reassoc-32.c
gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c
gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c
gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c
gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-11.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-14.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-16.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-18.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-4.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-1.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-2.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-3.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-4.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-5.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-6.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-11.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-14.c
gcc/testsuite/gcc.dg/tree-ssa/vrp47.c
gcc/testsuite/gcc.dg/tree-ssa/vrp87.c
gcc/testsuite/lib/target-supports.exp
gcc/tree-ssa-ifcombine.c

index 0bf512d35a9f56946a4ac2bcb2c4ec1a6638b852..f319daf14cf0a8a8276a0914a0dbe3e1a68cef47 100644 (file)
@@ -1,3 +1,12 @@
+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.
+
 2018-11-30  Jeff Law  <law@redhat.com>
 
        * optabs.c (expand_binop): Use "machine_mode" rather than
index 5399288dfc5fcdca07d67b2c6ff644119f200afd..45de94c93c5278ebedd698aa0eba481ce91fe93e 100644 (file)
@@ -5572,12 +5572,15 @@ fold_range_test (location_t loc, enum tree_code code, tree type,
   /* 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
@@ -8229,7 +8232,11 @@ fold_truth_andor (location_t loc, enum tree_code code, tree type,
   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 11396a7f3af3133d2a93175b3330f3bd5bfc15db..982f180a312a54d4c8c8ed3eb82c5a4f49f02546 100644 (file)
@@ -1360,6 +1360,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 903f7cb34047233981420044ca65e53cfaeb9a66..b48e353d05d913c55ee0053a89766b5239d08872 100644 (file)
@@ -1,3 +1,41 @@
+2018-11-30  Jakub Jelinek  <jakub@redhat.com>
+
+       PR testsuite/85368
+       * lib/target-supports.exp (logical_op_short_circuit): Remove.
+       * gcc.dg/builtin-bswap-7.c: Remove logical_op_short_circuit
+       effective target, drop -mbranch-cost= options from the test and
+       instead pass --param logical-op-non-short-circuit=0 or
+       --param logical-op-non-short-circuit=1 depending on what the
+       tests meant to test.
+       * gcc.dg/pr21643.c: Likewise.
+       * gcc.dg/tree-ssa/ssa-ifcombine-ccmp-2.c: Likewise.
+       * gcc.dg/tree-ssa/phi-opt-11.c: Likewise.
+       * gcc.dg/tree-ssa/ssa-ifcombine-ccmp-1.c: Likewise.
+       * gcc.dg/tree-ssa/ssa-dom-thread-4.c: Likewise.
+       * gcc.dg/tree-ssa/ssa-ifcombine-ccmp-3.c: Likewise.
+       * gcc.dg/tree-ssa/ssa-thread-14.c: Likewise.
+       * gcc.dg/tree-ssa/vrp47.c: Likewise.
+       * gcc.dg/tree-ssa/ssa-dom-thread-11.c: Likewise.
+       * gcc.dg/tree-ssa/ssa-dom-thread-16.c: Likewise.
+       * gcc.dg/tree-ssa/ssa-dom-thread-14.c: Likewise.
+       * gcc.dg/tree-ssa/ssa-ifcombine-ccmp-5.c: Likewise.
+       * gcc.dg/tree-ssa/vrp87.c: Likewise.
+       * gcc.dg/tree-ssa/ssa-ifcombine-ccmp-6.c: Likewise.
+       * gcc.dg/tree-ssa/phi-opt-2.c: Likewise.
+       * gcc.dg/tree-ssa/ssa-ifcombine-13.c: Likewise.
+       * gcc.dg/tree-ssa/ssa-thread-11.c: Likewise.
+       * gcc.dg/tree-ssa/ssa-ifcombine-ccmp-4.c: Likewise.
+       * gcc.dg/tree-ssa/forwprop-28.c: Likewise.
+       * gcc.dg/binop-xor1.c: Likewise.
+       * gcc.dg/pr46309.c: Likewise.
+       * gcc.dg/tree-ssa/ssa-dom-thread-18.c: New test.
+       * gcc.dg/tree-ssa/reassoc-32.c: Add
+       --param logical-op-non-short-circuit=1 to dg-options.
+       * gcc.dg/tree-ssa/reassoc-33.c: Likewise.
+       * gcc.dg/tree-ssa/reassoc-34.c: Likewise.
+       * gcc.dg/tree-ssa/reassoc-35.c: Likewise.
+       * gcc.dg/tree-ssa/reassoc-36.c: Likewise.
+
 2018-11-30  Wilco Dijkstra  <wdijkstr@arm.com>
 
        PR middle-end/64242
index e2ea938dd91a618bb85ce7bde51dff6f4a6a4dae..dea11e50d5d284a84cb40060a8a27df5b83b363b 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fdump-tree-optimized --param logical-op-non-short-circuit=1" } */
 
 int
 foo (int a, int b, int c)
@@ -7,4 +7,4 @@ foo (int a, int b, int c)
   return ((a && !b && c) || (!a && b && c));
 }
 
-/* { dg-final { scan-tree-dump-times "\\\^" 1 "optimized" { xfail logical_op_short_circuit } } } */
+/* { dg-final { scan-tree-dump-times "\\\^" 1 "optimized" } } */
index fe854416c40a677dce127253f1dfefcdd63b5987..35bcee3784794e859373db68c830a5e764c62868 100644 (file)
@@ -3,9 +3,9 @@
 /* { dg-require-effective-target lp64 } */
 /* { dg-options "-O -fdump-rtl-combine" } */
 
-/* The branch cost setting prevents the return value from being
+/* The param setting prevents the return value from being
    calculated with arithmetic instead of doing a compare.  */
-/* { dg-additional-options "-mbranch-cost=0" { target branch_cost } } */
+/* { dg-additional-options "--param logical-op-non-short-circuit=0" } */
 
 #include <stdint.h>
 
index 8a721650aa3c565d3a997f78812dd0cdae725dd5..4e7f93d351ab15cfae95f54fb441e7b3ea586a87 100644 (file)
@@ -1,7 +1,6 @@
 /* PR tree-optimization/21643 */
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-reassoc1-details" } */
-/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
+/* { dg-options "-O2 -fdump-tree-reassoc1-details --param logical-op-non-short-circuit=1" } */
 
 int
 f1 (unsigned char c)
@@ -87,5 +86,4 @@ f9 (unsigned char c)
   return 1;
 }
 
-/* { dg-final { scan-tree-dump-times "Optimizing range tests c_\[0-9\]*.D. -.0, 31. and -.32, 32.\[\n\r\]* into" 6 "reassoc1" { target { ! logical_op_short_circuit } } } }  */
-/* { dg-final { scan-tree-dump-times "Optimizing range tests c_\[0-9\]*.D. -.0, 31. and -.32, 32.\[\n\r\]* into" 5 "reassoc1" { target logical_op_short_circuit } } } */
+/* { dg-final { scan-tree-dump-times "Optimizing range tests c_\[0-9\]*.D. -.0, 31. and -.32, 32.\[\n\r\]* into" 6 "reassoc1" } }  */
index c9645292c6fbf0dadc7cfa2886c23d3383199401..615d6574ef97ed393f3ab2ba58e71556d18b1ef5 100644 (file)
@@ -1,10 +1,6 @@
 /* PR tree-optimization/46309 */
-/* { dg-do compile { target { { ! logical_op_short_circuit } || { mips*-*-* avr*-*-* } } } } */
-/* { dg-options "-O2 -fdump-tree-reassoc-details" } */
-/* The transformation depends on BRANCH_COST being greater than 1
-   (see the notes in the PR), so try to force that.  */
-/* { dg-additional-options "-mtune=octeon2" { target mips*-*-* } } */
-/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-reassoc-details --param logical-op-non-short-circuit=1" } */
 
 int
 f1 (int a)
index aa70678f4cd4643b782fae9c79158357bfbab83c..4f88a2674b6590ec415c446b3e8e523af6e134c2 100644 (file)
@@ -1,7 +1,7 @@
 /* Setting LOGICAL_OP_NON_SHORT_CIRCUIT to 0 leads to two conditional jumps
    when evaluating an && condition.  VRP is not able to optimize this.  */
-/* { dg-do compile { target { ! { logical_op_short_circuit || { m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* } } } } } */
-/* { dg-options "-O2 -fdump-tree-forwprop1-details" } */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-forwprop1-details --param logical-op-non-short-circuit=1" } */
 
 extern char *frob (void);
 extern _Bool testit (void);
index cccb06927df6cf0e34b2cc2637f12d381806739f..14c82cd52165477b6c9bc1a5f731469eb5666627 100644 (file)
@@ -1,6 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-optimized" } */
-/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
+/* { dg-options "-O1 -fdump-tree-optimized --param logical-op-non-short-circuit=1" } */
 
 int f(int a, int b, int c)
 {
@@ -23,5 +22,4 @@ int h(int a, int b, int c, int d)
  return a;
 }
 
-/* { dg-final { scan-tree-dump-times "if" 0 "optimized" { target { { ! logical_op_short_circuit } || branch_cost } } } } */
-/* { dg-final { scan-tree-dump-times "if" 2 "optimized" { target { logical_op_short_circuit && { ! branch_cost } } } } } */
+/* { dg-final { scan-tree-dump-times "if" 0 "optimized" } } */
index e0b261810382083253ca8b76156bf5847c518484..5c7815e2c1a1951527c2217131c4d3dcabb58a7d 100644 (file)
@@ -1,6 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-optimized" } */
-/* { dg-additional-options "-mbranch-cost=1" { target branch_cost } } */
+/* { dg-options "-O1 -fdump-tree-optimized --param logical-op-non-short-circuit=0" } */
 
 _Bool f1(_Bool a, _Bool b)
 {
@@ -21,4 +20,4 @@ _Bool f1(_Bool a, _Bool b)
    which can be fixed in a different patch).
    Test this only when known to be !LOGICAL_OP_NON_SHORT_CIRCUIT,
    otherwise ifcombine may convert this into return a & b;.  */
-/* { dg-final { scan-tree-dump-times "if" 1 "optimized" { target { i?86-*-* x86_64-*-* mips*-*-* s390*-*-* avr*-*-* } } } } */
+/* { dg-final { scan-tree-dump-times "if" 1 "optimized" } } */
index b6ca8e2bb39e762561d65b22a6029cc74c22b876..944362ad076fc443131ac127d55c2919630ce95d 100644 (file)
@@ -1,6 +1,6 @@
 /* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-*"} } } */
 
-/* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */
+/* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details --param logical-op-non-short-circuit=1" } */
 /* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
 
 
index 243508c872ca36538f386826d785836971df4329..28cd7799ce1a1be642ef6c3ea5879c6848d7fcbf 100644 (file)
@@ -1,6 +1,6 @@
 /* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-* or1k-*-*-*"} } } */
 
-/* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */
+/* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details --param logical-op-non-short-circuit=1" } */
 /* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
 
 int test (int a, int b, int c)
index 24070046ef2534c652119e1cb164cb91ba81d5d2..f1087113f5154d8e5305d7facc21d09ebd2a3f60 100644 (file)
@@ -1,6 +1,6 @@
 /* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-* or1k*-*-*"} } } */
 
-/* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */
+/* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details --param logical-op-non-short-circuit=1" } */
 /* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
 
 int test (int a, int b, int c)
index e5ba101e00117228396d2714e697b7bfe925e781..98ea2ad9ebe1844be113dc9df829dce7545dd237 100644 (file)
@@ -1,6 +1,6 @@
 /* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-* or1k*-*-*"} } } */
 
-/* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */
+/* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details --param logical-op-non-short-circuit=1" } */
 /* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
 
 int test (unsigned int a, int b, int c)
index 4df5840859c534276416ec8132348ebe386db8a3..d91841023833e31abd7e42452401688c4bd25dac 100644 (file)
@@ -1,6 +1,6 @@
 /* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-* or1k*-*-*"} } } */
 
-/* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */
+/* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details --param logical-op-non-short-circuit=1" } */
 /* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
 
 int test (int a, int b, int c)
index f42d64bed7102e4822bf0ca7948f2054950510f8..5f90613263d3d013ff02097d1504ae3952a3907e 100644 (file)
@@ -1,5 +1,5 @@
-/* { dg-do compile { target { ! logical_op_short_circuit  } } } */
-/* { dg-options "-O2 -fdump-tree-dom2-details" } */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-dom2-details --param logical-op-non-short-circuit=1" } */
 
 static int *bb_ticks;
 extern void frob (void);
index 2d97f86fa28eef6fb90608a5c9ea54da086d76ba..4e6a911506e17dfa78f318668f7490f38a875c8f 100644 (file)
@@ -1,5 +1,5 @@
-/* { dg-do compile { target { ! logical_op_short_circuit  } } } */
-/* { dg-options "-O2 -fdump-tree-dom2-details -w" } */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-dom2-details -w --param logical-op-non-short-circuit=1" } */
 
 enum optab_methods
 {
index e2e0d20fb9fb9b641b12ba17c04cb3fd6c32c3c0..ffbdc988e0a1c75b4f69b43fc6ac8c9a2f0a3b96 100644 (file)
@@ -1,5 +1,5 @@
-/* { dg-do compile { target { ! logical_op_short_circuit  } } } */
-/* { dg-options "-O2 -fdump-tree-dom2-details -w" } */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-dom2-details -w --param logical-op-non-short-circuit=1" } */
 unsigned char
 validate_subreg (unsigned int offset, unsigned int isize, unsigned int osize, int zz, int qq)
 {
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-18.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-18.c
new file mode 100644 (file)
index 0000000..d4759b8
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do compile } */ 
+/* { dg-options "-O2 -fdump-tree-vrp1-details -fdump-tree-dom2-details -std=gnu89 --param logical-op-non-short-circuit=0" } */
+
+#include "ssa-dom-thread-4.c"
+
+/* On targets that define LOGICAL_OP_NON_SHORT_CIRCUIT to 0, we split both
+   "a_elt || b_elt" and "b_elt && kill_elt" into two conditions each,
+   rather than using "(var1 != 0) op (var2 != 0)".  Also, as on other targets,
+   we duplicate the header of the inner "while" loop.  There are then
+   4 threading opportunities:
+
+   1x "!a_elt && b_elt" in the outer "while" loop
+      -> the start of the inner "while" loop,
+        skipping the known-true "b_elt" in the first condition.
+   1x "!b_elt" in the first condition
+      -> the outer "while" loop's continuation point,
+        skipping the known-false "b_elt" in the second condition.
+   2x "kill_elt->indx >= b_elt->indx" in the first "while" loop
+      -> "kill_elt->indx == b_elt->indx" in the second condition,
+        skipping the known-true "b_elt && kill_elt" in the second
+        condition.
+
+   All the cases are picked up by VRP1 as jump threads.  */
+/* { dg-final { scan-tree-dump-times "Threaded" 4 "vrp1" } } */
index e13eb8673dd7d0db339e4e58291f4ec68bea404a..521754f8d7960a9b42f1de7159fd64d367b7e1d3 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */ 
-/* { dg-options "-O2 -fdump-tree-vrp1-details -fdump-tree-dom2-details -std=gnu89" } */
+/* { dg-options "-O2 -fdump-tree-vrp1-details -fdump-tree-dom2-details -std=gnu89 --param logical-op-non-short-circuit=1" } */
 struct bitmap_head_def;
 typedef struct bitmap_head_def *bitmap;
 typedef const struct bitmap_head_def *const_bitmap;
@@ -58,25 +58,4 @@ bitmap_ior_and_compl (bitmap dst, const_bitmap a, const_bitmap b,
    code we missed the edge when the first conditional is false
    (b_elt is zero, which means the second conditional is always
    zero.  VRP1 catches all three.  */
-/* { dg-final { scan-tree-dump-times "Threaded" 3 "vrp1" { target { ! logical_op_short_circuit } } } } */
-
-/* On targets that define LOGICAL_OP_NON_SHORT_CIRCUIT to 0, we split both
-   "a_elt || b_elt" and "b_elt && kill_elt" into two conditions each,
-   rather than using "(var1 != 0) op (var2 != 0)".  Also, as on other targets,
-   we duplicate the header of the inner "while" loop.  There are then
-   4 threading opportunities:
-
-   1x "!a_elt && b_elt" in the outer "while" loop
-      -> the start of the inner "while" loop,
-        skipping the known-true "b_elt" in the first condition.
-   1x "!b_elt" in the first condition
-      -> the outer "while" loop's continuation point,
-        skipping the known-false "b_elt" in the second condition.
-   2x "kill_elt->indx >= b_elt->indx" in the first "while" loop
-      -> "kill_elt->indx == b_elt->indx" in the second condition,
-        skipping the known-true "b_elt && kill_elt" in the second
-        condition.
-
-   All the cases are picked up by VRP1 as jump threads.  */
-/* { dg-final { scan-tree-dump-times "Threaded" 4 "vrp1" { target logical_op_short_circuit } } } */
-
+/* { dg-final { scan-tree-dump-times "Threaded" 3 "vrp1" } } */
index 5f3147a8c004fe679dbd76e9483a820e50fa0646..425eb3d64811a7d008fad70768e934b4ee38a275 100644 (file)
@@ -1,6 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-optimized-details-blocks" } */
-/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
+/* { dg-options "-O1 -fdump-tree-optimized-details-blocks --param logical-op-non-short-circuit=1" } */
 
 _Bool f1(_Bool a, _Bool b)
 {
@@ -17,5 +16,5 @@ _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 "if" "optimized" } } */
 /* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */
index 1714fcf97c0501a960cb8ac7f9fe7950ffb5301c..a550d00fd22bc3d18aa8c999b7ffb409a2ea72ce 100644 (file)
@@ -1,7 +1,5 @@
-/* { dg-do compile { target { ! { { logical_op_short_circuit && { ! avr-*-* } } || { m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* arc*-*-* mips*-*-* } } } } } */
-
-/* { dg-options "-O2 -g -fdump-tree-optimized" } */
-/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g -fdump-tree-optimized --param logical-op-non-short-circuit=1" } */
 
 int t (int a, int b)
 {
index f35ec5edac23784af738ccca0a60f8ac99490b1f..6d947c1604bde6ce85f3a614010651641785110e 100644 (file)
@@ -1,7 +1,5 @@
-/* { dg-do compile { target { ! { { logical_op_short_circuit && { ! avr-*-* } } || { m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* arc*-*-* mips*-*-* } } } } } */
-
-/* { dg-options "-O2 -g -fdump-tree-optimized" } */
-/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g -fdump-tree-optimized --param logical-op-non-short-circuit=1" } */
 
 int t (int a, int b)
 {
index d84bdd51c749eaf6de0613721a9328cd97d5c866..353e4176cc2d36e83887f34e88db1c32e964b66c 100644 (file)
@@ -1,7 +1,5 @@
-/* { dg-do compile { target { ! { { logical_op_short_circuit && { ! avr-*-* } } || { m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* arc*-*-* mips*-*-* } } } } } */
-
-/* { dg-options "-O2 -g -fdump-tree-optimized" } */
-/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g -fdump-tree-optimized --param logical-op-non-short-circuit=1" } */
 
 int t (int a, int b)
 {
index be0ee264e359927958ae2cd62eaddb0b0d657877..76f40178d37b461ef4c35659804bed1274ad4f4c 100644 (file)
@@ -1,7 +1,5 @@
-/* { dg-do compile { target { ! { { logical_op_short_circuit && { ! avr-*-* } } || { m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* arc*-*-* mips*-*-* } } } } } */
-
-/* { dg-options "-O2 -g -fdump-tree-optimized" } */
-/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g -fdump-tree-optimized --param logical-op-non-short-circuit=1" } */
 
 int t (int a, int b)
 {
index 09c22abb071aa5fd8bee0536a85b6f662fac20df..0c048335237e8dcf07bf26c510fc6118611d0645 100644 (file)
@@ -1,7 +1,5 @@
-/* { dg-do compile { target { ! { { logical_op_short_circuit && { ! avr-*-* } } || { m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* arc*-*-* mips*-*-* } } } } } */
-
-/* { dg-options "-O2 -g -fdump-tree-optimized" } */
-/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g -fdump-tree-optimized --param logical-op-non-short-circuit=1" } */
 
 int t (int a, int b, int c)
 {
index a0dc82db1564ab730390a827cca9df3d20c7e292..02404a6679f5286dc980859e43d339b7f5f03174 100644 (file)
@@ -1,7 +1,5 @@
-/* { dg-do compile { target { ! { { logical_op_short_circuit && { ! avr-*-* } } || { m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* arc*-*-* mips*-*-* } } } } } */
-
-/* { dg-options "-O2 -g -fdump-tree-optimized" } */
-/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g -fdump-tree-optimized --param logical-op-non-short-circuit=1" } */
 
 int t (int a, int b, int c)
 {
index 70decd184a72902b68300d993b2fb6431e66c573..67e1e89ecd3305c580cbac2a4f5cec347c9aca69 100644 (file)
@@ -1,5 +1,5 @@
-/* { dg-do compile { target { ! { logical_op_short_circuit || { m68k*-*-* bfin*-*-* v850*-*-* moxie*-*-* m32c*-*-* fr30*-*-* mcore*-*-* frv-*-* h8300-*-* m32r-*-* mn10300-*-* msp430-*-* pdp11-*-* rl78-*-* rx-*-* vax-*-*} } } } } */
-/* { dg-options "-O2 -fdump-tree-vrp2-details" } */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp2-details --param logical-op-non-short-circuit=1" } */
 /* { dg-final { scan-tree-dump-not "IRREDUCIBLE_LOOP" "vrp2" } } */
 
 void abort (void);
index f12fb07e604c4a8d95642c10800917bd8ebce143..38661c888220568b4155708253e5509a93e6a123 100644 (file)
@@ -1,6 +1,5 @@
-/* { dg-do compile { target { ! { logical_op_short_circuit || { m68k*-*-* mmix*-*-* mep*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-* riscv*-*-* } } } } }  */
-/* { dg-additional-options "-O2 -fdump-tree-vrp-details" }  */
-/* { dg-additional-options "-mbranch-cost=2" { target i?86-*-* x86_64-*-* } }  */
+/* { dg-do compile } */
+/* { dg-additional-options "-O2 -fdump-tree-vrp-details --param logical-op-non-short-circuit=1" }  */
 /* { dg-final { scan-tree-dump-times "Threaded jump" 8 "vrp1" } }  */
 
 void foo (void);
index 28a8808e8e96f40ba7cb8626c1abbb362a61ac45..eb7546c4873c24c7bd02fcae733a348620210e7c 100644 (file)
@@ -1,10 +1,7 @@
 /* Setting LOGICAL_OP_NON_SHORT_CIRCUIT to 0 inhibits the setcc
    optimizations that expose the VRP opportunity.  */
-/* Skip on S/390.  Lower values in BRANCH_COST lead to two conditional
-   jumps when evaluating an && condition.  VRP is not able to optimize
-   this.  */
-/* { dg-do compile { target { ! { logical_op_short_circuit || { s390*-*-* mn10300-*-* hppa*-*-* m68k*-*-* } } } } } */
-/* { dg-options "-O2 -fdump-tree-vrp1 -fdump-tree-dom2 -fdump-tree-vrp2" } */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp1 -fdump-tree-dom2 -fdump-tree-vrp2 --param logical-op-non-short-circuit=1" } */
 /* { dg-additional-options "-march=i586" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
 
 int h(int x, int y)
index 1080ab1723b4991ffbeae6542d9643c9952525cb..da1d0a2d80c1d73a9ae19efe1133c5f331127b1f 100644 (file)
@@ -1,8 +1,7 @@
 /* Setting LOGICAL_OP_NON_SHORT_CIRCUIT to 0 leads to two conditional jumps
    when evaluating an && condition.  */
-/* { dg-do compile { target { ! { logical_op_short_circuit || { m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* } } } } } */
-
-/* { dg-options "-O2 -fdump-tree-fre1-details" } */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-fre1-details --param logical-op-non-short-circuit=1" } */
 
 struct bitmap_head_def;
 typedef struct bitmap_head_def *bitmap;
index 3baa2da25ea12c19d5c6f9364c64048d61eb91a0..faa67e22321724daebc7f2d2c4158a1f29542bfc 100644 (file)
@@ -8487,29 +8487,6 @@ proc check_effective_target_tiny {} {
     }]
 }
 
-# Return 1 if LOGICAL_OP_NON_SHORT_CIRCUIT is set to 0 for the current target.
-
-proc check_effective_target_logical_op_short_circuit {} {
-    if { [istarget mips*-*-*]
-        || [istarget arc*-*-*]
-        || [istarget avr*-*-*]
-        || [istarget crisv32-*-*] || [istarget cris-*-*]
-        || [istarget csky*-*-*]
-        || [istarget mmix-*-*]
-        || [istarget msp430-*-*]
-        || [istarget s390*-*-*]
-        || [istarget powerpc*-*-*]
-        || [istarget nios2*-*-*]
-        || [istarget riscv*-*-*]
-        || [istarget v850*-*-*]
-        || [istarget visium-*-*]
-        || [istarget or1k*-*-*]
-        || [check_effective_target_arm_cortex_m] } {
-       return 1
-    }
-    return 0
-}
-
 # Return 1 if the target supports -mbranch-cost=N option.
 
 proc check_effective_target_branch_cost {} {
index 2b969378d6506ece0f640b05cd15894f5fb4b406..ddb9564298bc05f75952dc2977602020c949a2e0 100644 (file)
@@ -40,6 +40,7 @@ along with GCC; see the file COPYING3.  If not see
 #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 \
@@ -563,7 +564,11 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv,
        {
          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)))