re PR tree-optimization/35716 (gfortran.dg/assign_6.f and gfortran.dg/g77/dnrm2.f)
authorRichard Guenther <rguenther@suse.de>
Thu, 27 Mar 2008 17:09:54 +0000 (17:09 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 27 Mar 2008 17:09:54 +0000 (17:09 +0000)
2008-03-27  Richard Guenther  <rguenther@suse.de>

PR middle-end/35716
* fold-const.c (fold_comparison): Restrict distinct decl
comparison folding to VAR_DECLs and PARM_DECLs.  Do not
solely rely on operand_equal_p.

From-SVN: r133647

gcc/ChangeLog
gcc/fold-const.c

index 19cb5670f755c6a8b8c3621373ad77533b0a9e7f..529c23062a2ebb7f7f2dbfde69da39ff36e332cf 100644 (file)
@@ -1,3 +1,10 @@
+2008-03-27  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/35716
+       * fold-const.c (fold_comparison): Restrict distinct decl
+       comparison folding to VAR_DECLs and PARM_DECLs.  Do not
+       solely rely on operand_equal_p.
+
 2008-03-27  Richard Guenther  <rguenther@suse.de>
 
        PR c/32511
index a7dcfc3ff90885cb342fc2297fbbdf9a4e81f793..fe78e6d76cf883c553a9ff10fd5cd537065ff35b 100644 (file)
@@ -8584,14 +8584,18 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1)
         of local binding decls or constants.  */
       else if (indirect_base0 && indirect_base1
               /* We know that !operand_equal_p (base0, base1, 0)
-                 because the if condition was false.  */
+                 because the if condition was false.  But make
+                 sure two decls are not the same.  */
+              && base0 != base1
               && TREE_CODE (arg0) == ADDR_EXPR
               && TREE_CODE (arg1) == ADDR_EXPR
-              && ((DECL_P (base0)
+              && (((TREE_CODE (base0) == VAR_DECL
+                    || TREE_CODE (base0) == PARM_DECL)
                    && (targetm.binds_local_p (base0)
                        || CONSTANT_CLASS_P (base1)))
                   || CONSTANT_CLASS_P (base0))
-              && ((DECL_P (base1)
+              && (((TREE_CODE (base1) == VAR_DECL
+                    || TREE_CODE (base1) == PARM_DECL)
                    && (targetm.binds_local_p (base1)
                        || CONSTANT_CLASS_P (base0)))
                   || CONSTANT_CLASS_P (base1)))