]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2015-07-24 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 24 Jul 2015 08:31:07 +0000 (08:31 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 24 Jul 2015 08:31:07 +0000 (08:31 +0000)
* genmatch.c (add_operator): Allow SSA_NAME as predicate.
* fold-const.c (fold_comparison): Move parameter does not
alias &local simplification ...
* match.pd: ... as a pattern here.

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

gcc/ChangeLog
gcc/fold-const.c
gcc/genmatch.c
gcc/match.pd

index 47f7237d224ff7d51b2c80a27aa65a1085610c4e..515f8ad3d3d9b3c5680452fa9c6469a0cfcba6f5 100644 (file)
@@ -1,3 +1,10 @@
+2015-07-24  Richard Biener  <rguenther@suse.de>
+
+       * genmatch.c (add_operator): Allow SSA_NAME as predicate.
+       * fold-const.c (fold_comparison): Move parameter does not
+       alias &local simplification ...
+       * match.pd: ... as a pattern here.
+
 2015-07-24  Richard Biener  <rguenther@suse.de>
 
        * gimple-fold.c (replace_stmt_with_simplification): Special-case
index 886922fcbcfaae24f90d991404c0d583d0a4173b..54a6b13df29f2c7353a7982b4d7d63de67cdd3fd 100644 (file)
@@ -8467,33 +8467,9 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
            }
        }
 
-      /* A local variable can never be pointed to by
-         the default SSA name of an incoming parameter.  */
-      if ((TREE_CODE (arg0) == ADDR_EXPR
-           && indirect_base0
-           && TREE_CODE (base0) == VAR_DECL
-           && auto_var_in_fn_p (base0, current_function_decl)
-           && !indirect_base1
-           && TREE_CODE (base1) == SSA_NAME
-           && SSA_NAME_IS_DEFAULT_DEF (base1)
-          && TREE_CODE (SSA_NAME_VAR (base1)) == PARM_DECL)
-          || (TREE_CODE (arg1) == ADDR_EXPR
-              && indirect_base1
-              && TREE_CODE (base1) == VAR_DECL
-              && auto_var_in_fn_p (base1, current_function_decl)
-              && !indirect_base0
-              && TREE_CODE (base0) == SSA_NAME
-              && SSA_NAME_IS_DEFAULT_DEF (base0)
-             && TREE_CODE (SSA_NAME_VAR (base0)) == PARM_DECL))
-        {
-          if (code == NE_EXPR)
-            return constant_boolean_node (1, type);
-          else if (code == EQ_EXPR)
-            return constant_boolean_node (0, type);
-        }
       /* If we have equivalent bases we might be able to simplify.  */
-      else if (indirect_base0 == indirect_base1
-               && operand_equal_p (base0, base1, 0))
+      if (indirect_base0 == indirect_base1
+         && operand_equal_p (base0, base1, 0))
        {
          /* We can fold this expression to a constant if the non-constant
             offset parts are equal.  */
index b4ab7b56e7231a40667556f843c685b44660a0c6..cb2377095fe91a5d10f8a1542cc4f08306b7c6d7 100644 (file)
@@ -395,7 +395,9 @@ add_operator (enum tree_code code, const char *id,
       /* To have INTEGER_CST and friends as "predicate operators".  */
       && strcmp (tcc, "tcc_constant") != 0
       /* And allow CONSTRUCTOR for vector initializers.  */
-      && !(code == CONSTRUCTOR))
+      && !(code == CONSTRUCTOR)
+      /* Allow SSA_NAME as predicate operator.  */
+      && !(code == SSA_NAME))
     return;
   /* Treat ADDR_EXPR as atom, thus don't allow matching its operand.  */
   if (code == ADDR_EXPR)
index 2ee36dec1ed212c009741997d622729a7b018177..ccc5165f320bae1bd79aecdfe9d8ce251e1b1877 100644 (file)
@@ -1743,6 +1743,21 @@ along with GCC; see the file COPYING3.  If not see
           (if (cmp == GT_EXPR || cmp == GE_EXPR)
            { constant_boolean_node (above ? false : true, type); }))))))))))))
 
+(for cmp (eq ne)
+ /* A local variable can never be pointed to by
+    the default SSA name of an incoming parameter.
+    SSA names are canonicalized to 2nd place.  */
+ (simplify
+  (cmp addr@0 SSA_NAME@1)
+  (if (SSA_NAME_IS_DEFAULT_DEF (@1)
+       && TREE_CODE (SSA_NAME_VAR (@1)) == PARM_DECL)
+   (with { tree base = get_base_address (TREE_OPERAND (@0, 0)); }
+    (if (TREE_CODE (base) == VAR_DECL
+         && auto_var_in_fn_p (base, current_function_decl))
+     (if (cmp == NE_EXPR)
+      { constant_boolean_node (true, type); }
+      { constant_boolean_node (false, type); }))))))
+
 /* Equality compare simplifications from fold_binary  */
 (for cmp (eq ne)