match.pd (fold_widened_comparison): Apply simplifications to all integral types.
authorEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 26 Oct 2015 17:02:48 +0000 (17:02 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 26 Oct 2015 17:02:48 +0000 (17:02 +0000)
* match.pd (fold_widened_comparison): Apply simplifications to all
integral types.

From-SVN: r229384

gcc/ChangeLog
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/atomic-noinline-aux.c
gcc/testsuite/gcc.dg/atomic-noinline.c
gcc/testsuite/gnat.dg/opt51.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt51_pkg.ads [new file with mode: 0644]

index b2be8cf74113eb2a9027092a63725f993b783fb0..f90887f84b37585bbb8d5b9a3a77ad44a3ffa4c8 100644 (file)
@@ -1,4 +1,9 @@
-2015-10-26  Simon Dardis <simon.dardis@imgtec.com>
+2015-10-26  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * match.pd (fold_widened_comparison): Apply simplifications to all
+       integral types.
+
+2015-10-26  Simon Dardis  <simon.dardis@imgtec.com>
 
        * target.def (TARGET_NO_SPECULATION_IN_DELAY_SLOTS_P): New hook.
        * doc/tm.texi.in (TARGET_NO_SPECULATION_IN_DELAY_SLOTS_P): Document.
@@ -9,9 +14,8 @@
 2015-10-26  Jeff Law  <law@redhat.com>
 
        PR tree-optimization/68013
-       * tree-ssa-threadbackward.c
-       (fsm_find_control_statement_thread_paths): Make sure the first block
-       in the path is in VISITED_BBs.
+       * tree-ssa-threadbackward.c (fsm_find_control_statement_thread_paths):
+       Make sure the first block in the path is in VISITED_BBs.
 
 2015-10-26  Richard Biener  <rguenther@suse.de>
        Dominik Vogt  <vogt@linux.vnet.ibm.com>
index fa927b07f56156488ae1beb116d6b9b5434ec670..6535b597e957c22b86bfd205f9f58a1cd07a6125 100644 (file)
@@ -2099,12 +2099,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
                  && (TYPE_UNSIGNED (TREE_TYPE (@00))
                      == TYPE_UNSIGNED (TREE_TYPE (@10))))
              || (TREE_CODE (@10) == INTEGER_CST
-                 && (TREE_CODE (TREE_TYPE (@00)) == INTEGER_TYPE
-                     || TREE_CODE (TREE_TYPE (@00)) == BOOLEAN_TYPE)
+                 && INTEGRAL_TYPE_P (TREE_TYPE (@00))
                  && int_fits_type_p (@10, TREE_TYPE (@00)))))
       (cmp @00 (convert @10))
       (if (TREE_CODE (@10) == INTEGER_CST
-          && TREE_CODE (TREE_TYPE (@00)) == INTEGER_TYPE
+          && INTEGRAL_TYPE_P (TREE_TYPE (@00))
           && !int_fits_type_p (@10, TREE_TYPE (@00)))
        (with
        {
index 04700fbf8421bfc80dd94604b924994146e99a84..db008b260a3ea9030fc409289f0847f563d709ef 100644 (file)
@@ -1,3 +1,10 @@
+2015-10-26  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc.dg/atomic-noinline.c: Change test on __atomic_is_lock_free.
+       * gcc.dg/atomic-noinline-aux.c: Adjust accordingly.
+       * gnat.dg/opt51.adb: New test.
+       * gnat.dg/opt51_pkg.ads: New helper.
+
 2015-10-26  Simon Dardis  <simon.dardis@imgtec.com>
 
        * gcc.target/mips/ds-schedule-1.c: New.
index deab7ae1de36ff85532c4bc4181ef4996cbc604d..97989798fe5beaa388a049ab3ca2ffae9af39e43 100644 (file)
@@ -64,7 +64,8 @@ __atomic_fetch_nand_1 (unsigned char *p, unsigned char v, int i)
   return ret;
 }
 
-int __atomic_is_lock_free (int i, void *p)
+bool __atomic_is_lock_free (int i, void *p)
 {
-  return 10;
+  *(short *)p = 1;
+  return true;
 }
index b3490ea32606c694c76a029627535266154b992f..99912cc87e7963be3f6818738d7d130f7997b975 100644 (file)
 #include <stdlib.h>
 #include <stdbool.h>
 
-extern void abort();
+extern void abort (void);
 
-short as,bs,cs;
+short as,bs,cs,ds;
 char ac,bc,cc;
 
 int
-main ()
+main (void)
 {
 
   ac = __atomic_exchange_n (&bc, cc, __ATOMIC_RELAXED);
@@ -42,14 +42,9 @@ main ()
 
   /* This should be translated to __atomic_fetch_add for the library */
   as = __atomic_add_fetch (&cs, 10, __ATOMIC_RELAXED);
-
   if (cs != 1)
     abort ();
 
-  /* The fake external function should return 10.  */
-  if (__atomic_is_lock_free (4, 0) != 10)
-    abort ();
-   
   /* PR 51040 was caused by arithmetic code not patching up nand_fetch properly
      when used an an external function.  Look for proper return value here.  */
   ac = 0x3C;
@@ -57,8 +52,10 @@ main ()
   if (bc != ac)
     abort ();
 
+  if (!__atomic_is_lock_free (2, &ds))
+    abort ();
+  if (ds != 1)
+    abort ();
+
   return 0;
 }
-
-
-
diff --git a/gcc/testsuite/gnat.dg/opt51.adb b/gcc/testsuite/gnat.dg/opt51.adb
new file mode 100644 (file)
index 0000000..0d2c820
--- /dev/null
@@ -0,0 +1,20 @@
+-- { dg-do compile }
+-- { dg-options "-O2 -fdump-tree-optimized" }
+
+with Opt51_Pkg; use Opt51_Pkg;
+
+procedure Opt51 (E: Enum; F : out Float) is
+begin
+  case (E) is
+    when One =>
+      F := 1.0;
+    when Two =>
+      F := 2.0;
+    when Three =>
+      F := 3.0;
+    when others =>
+      raise Program_Error;
+  end case;
+end;
+
+-- { dg-final { scan-tree-dump-not "check_PE_Explicit_Raise" "optimized" } }
diff --git a/gcc/testsuite/gnat.dg/opt51_pkg.ads b/gcc/testsuite/gnat.dg/opt51_pkg.ads
new file mode 100644 (file)
index 0000000..8ce1817
--- /dev/null
@@ -0,0 +1,5 @@
+package Opt51_Pkg is
+
+  type Enum is (One, Two, Three);
+
+end Opt51_Pkg;