OSDN Git Service

* gcc.target/i386/branch-cost1.c: New test.
authorktietz <ktietz@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Oct 2011 11:50:42 +0000 (11:50 +0000)
committerktietz <ktietz@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Oct 2011 11:50:42 +0000 (11:50 +0000)
        * gcc.target/i386/branch-cost2.c: New test.
        * gcc.target/i386/branch-cost3.c: New test.
        * gcc.target/i386/branch-cost4.c: New test.

        * fold-const.c (simple_operand_p_2): Handle integral
        casts from boolean-operands.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180295 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/branch-cost1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/branch-cost2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/branch-cost3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/branch-cost4.c [new file with mode: 0644]

index 2350165..49c9a30 100644 (file)
@@ -1,3 +1,8 @@
+2011-10-21  Kai Tietz  <ktietz@redhat.com>
+
+       * fold-const.c (simple_operand_p_2): Handle integral
+       casts from boolean-operands.
+
 2011-10-21  Jan Hubicka  <jh@suse.cz>
 
        * cgraph.c (dump_cgraph_node): Dump alias flag.
index dc14576..a838c34 100644 (file)
@@ -3695,23 +3695,23 @@ simple_operand_p (const_tree exp)
 
 /* Subroutine for fold_truth_andor: determine if an operand is simple enough
    to be evaluated unconditionally.
-   I addition to simple_operand_p, we assume that comparisons and logic-not
-   operations are simple, if their operands are simple, too.  */
+   I addition to simple_operand_p, we assume that comparisons, conversions,
+   and logic-not operations are simple, if their operands are simple, too.  */
 
 static bool
 simple_operand_p_2 (tree exp)
 {
   enum tree_code code;
 
-  /* Strip any conversions that don't change the machine mode.  */
-  STRIP_NOPS (exp);
-
-  code = TREE_CODE (exp);
-
   if (TREE_SIDE_EFFECTS (exp)
       || tree_could_trap_p (exp))
     return false;
 
+  while (CONVERT_EXPR_P (exp))
+    exp = TREE_OPERAND (exp, 0);
+
+  code = TREE_CODE (exp);
+
   if (TREE_CODE_CLASS (code) == tcc_comparison)
     return (simple_operand_p (TREE_OPERAND (exp, 0))
            && simple_operand_p (TREE_OPERAND (exp, 1)));
index 8f1a1b3..c5e52a3 100644 (file)
@@ -1,3 +1,10 @@
+2011-10-21  Kai Tietz  <ktietz@redhat.com>
+
+       * gcc.target/i386/branch-cost1.c: New test.
+       * gcc.target/i386/branch-cost2.c: New test.
+       * gcc.target/i386/branch-cost3.c: New test.
+       * gcc.target/i386/branch-cost4.c: New test.
+
 2011-10-20  Steve Ellcey  <sje@cup.hp.com>
 
        * gcc.dg/vect/vect-120.c: Add vect_floatint_cvt requirement.
diff --git a/gcc/testsuite/gcc.target/i386/branch-cost1.c b/gcc/testsuite/gcc.target/i386/branch-cost1.c
new file mode 100644 (file)
index 0000000..ed873fa
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-gimple -mbranch-cost=0" } */
+
+extern int doo (void);
+
+int
+foo (int a, int b)
+{
+  if (a && b)
+   return doo ();
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "if " 2 "gimple" } } */
+/* { dg-final { scan-tree-dump-not " & " "gimple" } } */
+/* { dg-final { cleanup-tree-dump "gimple" } } */
diff --git a/gcc/testsuite/gcc.target/i386/branch-cost2.c b/gcc/testsuite/gcc.target/i386/branch-cost2.c
new file mode 100644 (file)
index 0000000..4d754d5
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-gimple -mbranch-cost=2" } */
+
+extern int doo (void);
+
+int
+foo (int a, int b)
+{
+  if (a && b)
+   return doo ();
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "if " 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times " & " 1 "gimple" } } */
+/* { dg-final { cleanup-tree-dump "gimple" } } */
diff --git a/gcc/testsuite/gcc.target/i386/branch-cost3.c b/gcc/testsuite/gcc.target/i386/branch-cost3.c
new file mode 100644 (file)
index 0000000..3b69f50
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-gimple -mbranch-cost=2" } */
+
+extern int doo (void);
+
+int
+foo (_Bool a, _Bool b)
+{
+  if (a && b)
+   return doo ();
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "if " 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times " & " 1 "gimple" } } */
+/* { dg-final { cleanup-tree-dump "gimple" } } */
diff --git a/gcc/testsuite/gcc.target/i386/branch-cost4.c b/gcc/testsuite/gcc.target/i386/branch-cost4.c
new file mode 100644 (file)
index 0000000..5904b0d
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-gimple -mbranch-cost=0" } */
+
+extern int doo (void);
+
+int
+foo (_Bool a, _Bool b)
+{
+  if (a && b)
+   return doo ();
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "if " 2 "gimple" } } */
+/* { dg-final { scan-tree-dump-not " & " "gimple" } } */
+/* { dg-final { cleanup-tree-dump "gimple" } } */