re PR target/65697 (__atomic memory barriers not strong enough for __sync builtins)
[gcc.git] / gcc / expr.c
index fd9a0763e8ce4445bc2b89218678b38514c7492d..408ae1a7a1f66349ce74e44cc82404526556348b 100644 (file)
@@ -22,7 +22,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tm.h"
 #include "rtl.h"
-#include "input.h"
 #include "alias.h"
 #include "symtab.h"
 #include "tree.h"
@@ -64,11 +63,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-ssa-alias.h"
 #include "internal-fn.h"
 #include "gimple-expr.h"
-#include "is-a.h"
 #include "gimple.h"
 #include "gimple-ssa.h"
-#include "plugin-api.h"
-#include "ipa-ref.h"
 #include "cgraph.h"
 #include "tree-ssanames.h"
 #include "target.h"
@@ -8428,11 +8424,7 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
         Thus the following special case checks need only
         check the second operand.  */
       if (TREE_CODE (treeop0) == INTEGER_CST)
-       {
-         tree t1 = treeop0;
-         treeop0 = treeop1;
-         treeop1 = t1;
-       }
+       std::swap (treeop0, treeop1);
 
       /* First, check if we have a multiplication of one signed and one
         unsigned operand.  */
@@ -8557,11 +8549,7 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
            def0 = get_def_for_expr (treeop1, NEGATE_EXPR);
            /* Swap operands if the 2nd operand is fed by a negate.  */
            if (def0)
-             {
-               tree tem = treeop0;
-               treeop0 = treeop1;
-               treeop1 = tem;
-             }
+             std::swap (treeop0, treeop1);
          }
        def2 = get_def_for_expr (treeop2, NEGATE_EXPR);
 
@@ -8608,11 +8596,7 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
         Thus the following special case checks need only
         check the second operand.  */
       if (TREE_CODE (treeop0) == INTEGER_CST)
-       {
-         tree t1 = treeop0;
-         treeop0 = treeop1;
-         treeop1 = t1;
-       }
+       std::swap (treeop0, treeop1);
 
       /* Attempt to return something suitable for generating an
         indexed address, for machines that support that.  */
@@ -9290,7 +9274,7 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
   rtx op0, op1, temp, decl_rtl;
   tree type;
   int unsignedp;
-  machine_mode mode, dmode;
+  machine_mode mode;
   enum tree_code code = TREE_CODE (exp);
   rtx subtarget, original_target;
   int ignore;
@@ -9421,8 +9405,7 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
       if (g == NULL
          && modifier == EXPAND_INITIALIZER
          && !SSA_NAME_IS_DEFAULT_DEF (exp)
-         && (optimize || !SSA_NAME_VAR (exp)
-             || DECL_IGNORED_P (SSA_NAME_VAR (exp)))
+         && (optimize || DECL_IGNORED_P (SSA_NAME_VAR (exp)))
          && stmt_is_replaceable_p (SSA_NAME_DEF_STMT (exp)))
        g = SSA_NAME_DEF_STMT (exp);
       if (g)
@@ -9501,18 +9484,15 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
       /* Ensure variable marked as used even if it doesn't go through
         a parser.  If it hasn't be used yet, write out an external
         definition.  */
-      if (exp)
-       TREE_USED (exp) = 1;
+      TREE_USED (exp) = 1;
 
       /* Show we haven't gotten RTL for this yet.  */
       temp = 0;
 
       /* Variables inherited from containing functions should have
         been lowered by this point.  */
-      if (exp)
-       context = decl_function_context (exp);
-      gcc_assert (!exp
-                 || SCOPE_FILE_SCOPE_P (context)
+      context = decl_function_context (exp);
+      gcc_assert (SCOPE_FILE_SCOPE_P (context)
                  || context == current_function_decl
                  || TREE_STATIC (exp)
                  || DECL_EXTERNAL (exp)
@@ -9536,8 +9516,7 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
          decl_rtl = use_anchored_address (decl_rtl);
          if (modifier != EXPAND_CONST_ADDRESS
              && modifier != EXPAND_SUM
-             && !memory_address_addr_space_p (exp ? DECL_MODE (exp)
-                                              : GET_MODE (decl_rtl),
+             && !memory_address_addr_space_p (DECL_MODE (exp),
                                               XEXP (decl_rtl, 0),
                                               MEM_ADDR_SPACE (decl_rtl)))
            temp = replace_equiv_address (decl_rtl,
@@ -9548,17 +9527,12 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
         if the address is a register.  */
       if (temp != 0)
        {
-         if (exp && MEM_P (temp) && REG_P (XEXP (temp, 0)))
+         if (MEM_P (temp) && REG_P (XEXP (temp, 0)))
            mark_reg_pointer (XEXP (temp, 0), DECL_ALIGN (exp));
 
          return temp;
        }
 
-      if (exp)
-       dmode = DECL_MODE (exp);
-      else
-       dmode = TYPE_MODE (TREE_TYPE (ssa_name));
-
       /* If the mode of DECL_RTL does not match that of the decl,
         there are two cases: we are dealing with a BLKmode value
         that is returned in a register, or we are dealing with
@@ -9566,23 +9540,22 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
         of the wanted mode, but mark it so that we know that it
         was already extended.  */
       if (REG_P (decl_rtl)
-         && dmode != BLKmode
-         && GET_MODE (decl_rtl) != dmode)
+         && DECL_MODE (exp) != BLKmode
+         && GET_MODE (decl_rtl) != DECL_MODE (exp))
        {
          machine_mode pmode;
 
          /* Get the signedness to be used for this variable.  Ensure we get
             the same mode we got when the variable was declared.  */
-         if (code != SSA_NAME)
-           pmode = promote_decl_mode (exp, &unsignedp);
-         else if ((g = SSA_NAME_DEF_STMT (ssa_name))
-                  && gimple_code (g) == GIMPLE_CALL
-                  && !gimple_call_internal_p (g))
+         if (code == SSA_NAME
+             && (g = SSA_NAME_DEF_STMT (ssa_name))
+             && gimple_code (g) == GIMPLE_CALL
+             && !gimple_call_internal_p (g))
            pmode = promote_function_mode (type, mode, &unsignedp,
                                           gimple_call_fntype (g),
                                           2);
          else
-           pmode = promote_ssa_mode (ssa_name, &unsignedp);
+           pmode = promote_decl_mode (exp, &unsignedp);
          gcc_assert (GET_MODE (decl_rtl) == pmode);
 
          temp = gen_lowpart_SUBREG (mode, decl_rtl);
@@ -10923,7 +10896,6 @@ do_store_flag (sepops ops, rtx target, machine_mode mode)
 {
   enum rtx_code code;
   tree arg0, arg1, type;
-  tree tem;
   machine_mode operand_mode;
   int unsignedp;
   rtx op0, op1;
@@ -11046,7 +11018,7 @@ do_store_flag (sepops ops, rtx target, machine_mode mode)
   if (TREE_CODE (arg0) == REAL_CST || TREE_CODE (arg0) == INTEGER_CST
       || TREE_CODE (arg0) == FIXED_CST)
     {
-      tem = arg0; arg0 = arg1; arg1 = tem;
+      std::swap (arg0, arg1);
       code = swap_condition (code);
     }