Patchwork [testsuite] : Adjust tree-ssa/builtin-expect-*.c tests for high cost-branching optimization

login
register
mail settings
Submitter Kai Tietz
Date Oct. 18, 2011, 11:33 a.m.
Message ID <e0229a1b-06cf-40ce-ad3c-9e14457ae573@zmail06.collab.prod.int.phx2.redhat.com>
Download mbox | patch
Permalink /patch/120409/
State New
Headers show

Comments

Kai Tietz - Oct. 18, 2011, 11:33 a.m.
Hello,

this patch adjusts __builtin_expect tests in tree-ssa so, that short-circuit branch optimization don't lead to fallout.  I've used here a multiplication, as simple substraction/addition might get optimized away.

ChangeLog

2011-10-18  Kai Tietz  <ktietz@redhat.com>

        * gcc.dg/tree-ssa/builtin-expect-1.c: Adjust test.
        * gcc.dg/tree-ssa/builtin-expect-2.c: Adjust test.
        * gcc.dg/tree-ssa/builtin-expect-3.c: Adjust test.
        * gcc.dg/tree-ssa/builtin-expect-4.c: Adjust test.
        * gcc.dg/tree-ssa/builtin-expect-5.c: Adjust test.


Regression tested for x86_64-unknown-linux-gnu. Ok for apply?

Regards,
Kai
Richard Guenther - Oct. 19, 2011, 8:27 a.m.
On Tue, Oct 18, 2011 at 1:33 PM, Kai Tietz <ktietz@redhat.com> wrote:
> Hello,
>
> this patch adjusts __builtin_expect tests in tree-ssa so, that short-circuit branch optimization don't lead to fallout.  I've used here a multiplication, as simple substraction/addition might get optimized away.
>
> ChangeLog
>
> 2011-10-18  Kai Tietz  <ktietz@redhat.com>
>
>        * gcc.dg/tree-ssa/builtin-expect-1.c: Adjust test.
>        * gcc.dg/tree-ssa/builtin-expect-2.c: Adjust test.
>        * gcc.dg/tree-ssa/builtin-expect-3.c: Adjust test.
>        * gcc.dg/tree-ssa/builtin-expect-4.c: Adjust test.
>        * gcc.dg/tree-ssa/builtin-expect-5.c: Adjust test.
>
>
> Regression tested for x86_64-unknown-linux-gnu. Ok for apply?

Ok.

Thanks,
Richard.

> Regards,
> Kai
>
> Index: gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-1.c
> ===================================================================
> --- gcc-head.orig/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-1.c
> +++ gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-1.c
> @@ -1,9 +1,9 @@
>  /* { dg-do compile } */
>  /* { dg-options "-O2 -fdump-tree-gimple" } */
>
> -f (int i, float j)
> +f (int i, float j, int i2, float j2)
>  {
> -  if (__builtin_expect (i > 0 && j, 0))
> +  if (__builtin_expect ((i * i2) > 0 && (j * j2), 0))
>     g ();
>  }
>
> Index: gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-2.c
> ===================================================================
> --- gcc-head.orig/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-2.c
> +++ gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-2.c
> @@ -1,9 +1,9 @@
>  /* { dg-do compile } */
>  /* { dg-options "-O2 -fdump-tree-gimple" } */
>
> -f (int i, float j)
> +f (int i, float j, int i2, float j2)
>  {
> -  if (__builtin_expect (i > 0 || j, 0))
> +  if (__builtin_expect ((i * i2) > 0 || (j * j2), 0))
>     ;
>   else
>     g ();
> Index: gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-3.c
> ===================================================================
> --- gcc-head.orig/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-3.c
> +++ gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-3.c
> @@ -1,9 +1,9 @@
>  /* { dg-do compile } */
>  /* { dg-options "-O2 -fdump-tree-gimple" } */
>
> -f (int i, float j)
> +f (int i, float j, int i2, float j2)
>  {
> -  if (__builtin_expect (i > 0 && j, 0))
> +  if (__builtin_expect ((i * i2) > 0 && (j * j2), 0))
>     a ();
>   else
>     b ();
> Index: gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-4.c
> ===================================================================
> --- gcc-head.orig/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-4.c
> +++ gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-4.c
> @@ -1,9 +1,9 @@
>  /* { dg-do compile } */
>  /* { dg-options "-O2 -fdump-tree-gimple" } */
>
> -f (int i, float j)
> +f (int i, float j, int i2, float j2)
>  {
> -  if (__builtin_expect (i > 0 || j, 0))
> +  if (__builtin_expect ((i * i2) > 0 || (j * j2), 0))
>     a ();
>   else
>     b ();
> Index: gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-5.c
> ===================================================================
> --- gcc-head.orig/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-5.c
> +++ gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-5.c
> @@ -1,9 +1,9 @@
>  /* { dg-do compile } */
>  /* { dg-options "-O2 -fdump-tree-forwprop" } */
>
> -f (int i, float j)
> +f (int i, float j, int i2, float j2)
>  {
> -  if (__builtin_expect (i > 0 && __builtin_expect (j != 0, 1), 0))
> +  if (__builtin_expect ((i * i2) > 0 && __builtin_expect ((j * j2) != 0, 1), 0))
>     a ();
>   else
>     b ();
>

Patch

Index: gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-1.c
===================================================================
--- gcc-head.orig/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-1.c
+++ gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-1.c
@@ -1,9 +1,9 @@ 
 /* { dg-do compile } */
 /* { dg-options "-O2 -fdump-tree-gimple" } */
 
-f (int i, float j) 
+f (int i, float j, int i2, float j2) 
 { 
-  if (__builtin_expect (i > 0 && j, 0)) 
+  if (__builtin_expect ((i * i2) > 0 && (j * j2), 0)) 
     g ();
 } 
 
Index: gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-2.c
===================================================================
--- gcc-head.orig/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-2.c
+++ gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-2.c
@@ -1,9 +1,9 @@ 
 /* { dg-do compile } */
 /* { dg-options "-O2 -fdump-tree-gimple" } */
 
-f (int i, float j) 
+f (int i, float j, int i2, float j2) 
 { 
-  if (__builtin_expect (i > 0 || j, 0))
+  if (__builtin_expect ((i * i2) > 0 || (j * j2), 0))
     ;
   else
     g ();
Index: gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-3.c
===================================================================
--- gcc-head.orig/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-3.c
+++ gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-3.c
@@ -1,9 +1,9 @@ 
 /* { dg-do compile } */
 /* { dg-options "-O2 -fdump-tree-gimple" } */
 
-f (int i, float j) 
+f (int i, float j, int i2, float j2) 
 { 
-  if (__builtin_expect (i > 0 && j, 0))
+  if (__builtin_expect ((i * i2) > 0 && (j * j2), 0))
     a ();
   else
     b ();
Index: gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-4.c
===================================================================
--- gcc-head.orig/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-4.c
+++ gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-4.c
@@ -1,9 +1,9 @@ 
 /* { dg-do compile } */
 /* { dg-options "-O2 -fdump-tree-gimple" } */
 
-f (int i, float j) 
+f (int i, float j, int i2, float j2) 
 { 
-  if (__builtin_expect (i > 0 || j, 0))
+  if (__builtin_expect ((i * i2) > 0 || (j * j2), 0))
     a ();
   else
     b ();
Index: gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-5.c
===================================================================
--- gcc-head.orig/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-5.c
+++ gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-5.c
@@ -1,9 +1,9 @@ 
 /* { dg-do compile } */
 /* { dg-options "-O2 -fdump-tree-forwprop" } */
 
-f (int i, float j) 
+f (int i, float j, int i2, float j2) 
 { 
-  if (__builtin_expect (i > 0 && __builtin_expect (j != 0, 1), 0))
+  if (__builtin_expect ((i * i2) > 0 && __builtin_expect ((j * j2) != 0, 1), 0))
     a ();
   else
     b ();