From: Jakub Jelinek Date: Tue, 12 Jul 2016 08:58:56 +0000 (+0200) Subject: re PR middle-end/71716 (gcc.dg/atomic/c11-atomic-exec-4.c is miscompiled with -march... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1de3c940d8782eae7739a6c6f7327e99eee63cce;p=gcc.git re PR middle-end/71716 (gcc.dg/atomic/c11-atomic-exec-4.c is miscompiled with -march=corei7) 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3c9432a67a7..58d5d873ae9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-07-12 Jakub Jelinek + + 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 PR rtl-optimization/68961 diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 36c105fc141..cbfcc2f0eae 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -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;