re PR middle-end/71716 (gcc.dg/atomic/c11-atomic-exec-4.c is miscompiled with -march...
authorJakub Jelinek <jakub@redhat.com>
Tue, 12 Jul 2016 08:58:56 +0000 (10:58 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 12 Jul 2016 08:58:56 +0000 (10:58 +0200)
PR middle-end/71716
* gimple-fold.c (optimize_atomic_compare_exchange_p): Return false
for SCALAR_FLOAT_TYPE_P type of expected var, or if TYPE_PRECISION
is different from mode's bitsize.  Small cleanup.

From-SVN: r238239

gcc/ChangeLog
gcc/gimple-fold.c

index 3c9432a67a7a189aecfc6f68d7692e67dd222e63..58d5d873ae9e788792f9df7d80df3026feebb6d9 100644 (file)
@@ -1,3 +1,10 @@
+2016-07-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/71716
+       * gimple-fold.c (optimize_atomic_compare_exchange_p): Return false
+       for SCALAR_FLOAT_TYPE_P type of expected var, or if TYPE_PRECISION
+       is different from mode's bitsize.  Small cleanup.
+
 2016-07-12  Richard Biener  <rguenther@suse.de>
 
        PR rtl-optimization/68961
index 36c105fc141cb8d48ba7d5679057331214ede91e..cbfcc2f0eae626f7437c97265c70330005da394b 100644 (file)
@@ -2984,12 +2984,19 @@ optimize_atomic_compare_exchange_p (gimple *stmt)
 
   tree expected = gimple_call_arg (stmt, 1);
   if (TREE_CODE (expected) != ADDR_EXPR
-      || !SSA_VAR_P (TREE_OPERAND (expected, 0))
-      || !is_gimple_reg_type (TREE_TYPE (TREE_OPERAND (expected, 0)))
+      || !SSA_VAR_P (TREE_OPERAND (expected, 0)))
+    return false;
+
+  tree etype = TREE_TYPE (TREE_OPERAND (expected, 0));
+  if (!is_gimple_reg_type (etype)
       || !auto_var_in_fn_p (TREE_OPERAND (expected, 0), current_function_decl)
-      || TREE_THIS_VOLATILE (TREE_TYPE (TREE_OPERAND (expected, 0)))
-      || TREE_CODE (TREE_TYPE (TREE_OPERAND (expected, 0))) == VECTOR_TYPE
-      || TREE_CODE (TREE_TYPE (TREE_OPERAND (expected, 0))) == COMPLEX_TYPE)
+      || TREE_THIS_VOLATILE (etype)
+      || VECTOR_TYPE_P (etype)
+      || TREE_CODE (etype) == COMPLEX_TYPE
+      /* Don't optimize floating point expected vars, VIEW_CONVERT_EXPRs
+        might not preserve all the bits.  See PR71716.  */
+      || SCALAR_FLOAT_TYPE_P (etype)
+      || TYPE_PRECISION (etype) != GET_MODE_BITSIZE (TYPE_MODE (etype)))
     return false;
 
   tree weak = gimple_call_arg (stmt, 3);
@@ -3005,8 +3012,7 @@ optimize_atomic_compare_exchange_p (gimple *stmt)
       && optab_handler (sync_compare_and_swap_optab, mode) == CODE_FOR_nothing)
     return false;
 
-  if (int_size_in_bytes (TREE_TYPE (TREE_OPERAND (expected, 0)))
-      != GET_MODE_SIZE (mode))
+  if (int_size_in_bytes (etype) != GET_MODE_SIZE (mode))
     return false;
 
   return true;