summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2012-06-21 16:49:20 +0000
committerpfg <pfg@FreeBSD.org>2012-06-21 16:49:20 +0000
commit8c84995be2f385f8e9a19b071c5297940a91c4dc (patch)
tree061d41c370879adcdbc7178c01ee3106fafc9a4b
parentdd83f274ed4c8fa3cdb0fd69be2f4df1e1ac398e (diff)
downloadFreeBSD-src-8c84995be2f385f8e9a19b071c5297940a91c4dc.zip
FreeBSD-src-8c84995be2f385f8e9a19b071c5297940a91c4dc.tar.gz
Bring a couple of fixes for gcc optimizations.
The GCC4.3 branch contains some optimization fixes that were not considered regressions and therefore were never backported. We are bringing a couple of them that are under GPLv2 since they were made before the license switch upstream. While here, add the GCC revision numbers in the log. Discussed with: jkim MFC after: 1 week
-rw-r--r--contrib/gcc/ChangeLog.gcc4322
-rw-r--r--contrib/gcc/fold-const.c8
-rw-r--r--contrib/gcc/gimplify.c4
-rw-r--r--contrib/gcc/tree-ssa-ccp.c4
-rw-r--r--contrib/gcc/tree-ssa-pre.c17
5 files changed, 45 insertions, 10 deletions
diff --git a/contrib/gcc/ChangeLog.gcc43 b/contrib/gcc/ChangeLog.gcc43
index 23b3a39..22ed9e8 100644
--- a/contrib/gcc/ChangeLog.gcc43
+++ b/contrib/gcc/ChangeLog.gcc43
@@ -5,6 +5,18 @@
with SSE3 instruction set support.
* doc/invoke.texi: Likewise.
+2007-04-12 Richard Guenther <rguenther@suse.de> (r123736)
+
+ PR tree-optimization/24689
+ PR tree-optimization/31307
+ * fold-const.c (operand_equal_p): Compare INTEGER_CST array
+ indices by value.
+ * gimplify.c (canonicalize_addr_expr): To be consistent with
+ gimplify_compound_lval only set operands two and three of
+ ARRAY_REFs if they are not gimple_min_invariant. This makes
+ it never at this place.
+ * tree-ssa-ccp.c (maybe_fold_offset_to_array_ref): Likewise.
+
2007-04-07 H.J. Lu <hongjiu.lu@intel.com> (r123639)
* config/i386/i386.c (ix86_handle_option): Handle SSSE3.
@@ -96,7 +108,7 @@
* doc/invoke.texi: Add entry about geode processor.
-2006-10-24 Richard Guenther <rguenther@suse.de>
+2006-10-24 Richard Guenther <rguenther@suse.de> (r118001)
PR middle-end/28796
* builtins.c (fold_builtin_classify): Use HONOR_INFINITIES
@@ -170,7 +182,13 @@
* doc/invoke.texi: Document -mssse3/-mno-ssse3 switches.
-2006-10-21 Richard Guenther <rguenther@suse.de>
+2006-10-21 Richard Guenther <rguenther@suse.de> (r117932)
+
+ PR tree-optimization/3511
+ * tree-ssa-pre.c (phi_translate): Fold CALL_EXPRs that
+ got new invariant arguments during PHI translation.
+
+2006-10-21 Richard Guenther <rguenther@suse.de> (r117929)
* builtins.c (fold_builtin_classify): Fix typo.
diff --git a/contrib/gcc/fold-const.c b/contrib/gcc/fold-const.c
index 37d99f8..1aadd30 100644
--- a/contrib/gcc/fold-const.c
+++ b/contrib/gcc/fold-const.c
@@ -2802,9 +2802,13 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags)
case ARRAY_REF:
case ARRAY_RANGE_REF:
- /* Operands 2 and 3 may be null. */
+ /* Operands 2 and 3 may be null.
+ Compare the array index by value if it is constant first as we
+ may have different types but same value here. */
return (OP_SAME (0)
- && OP_SAME (1)
+ && (tree_int_cst_equal (TREE_OPERAND (arg0, 1),
+ TREE_OPERAND (arg1, 1))
+ || OP_SAME (1))
&& OP_SAME_WITH_NULL (2)
&& OP_SAME_WITH_NULL (3));
diff --git a/contrib/gcc/gimplify.c b/contrib/gcc/gimplify.c
index 80dcd1a..7efae38 100644
--- a/contrib/gcc/gimplify.c
+++ b/contrib/gcc/gimplify.c
@@ -1600,9 +1600,7 @@ canonicalize_addr_expr (tree *expr_p)
/* All checks succeeded. Build a new node to merge the cast. */
*expr_p = build4 (ARRAY_REF, dctype, obj_expr,
TYPE_MIN_VALUE (TYPE_DOMAIN (datype)),
- TYPE_MIN_VALUE (TYPE_DOMAIN (datype)),
- size_binop (EXACT_DIV_EXPR, TYPE_SIZE_UNIT (dctype),
- size_int (TYPE_ALIGN_UNIT (dctype))));
+ NULL_TREE, NULL_TREE);
*expr_p = build1 (ADDR_EXPR, ctype, *expr_p);
}
diff --git a/contrib/gcc/tree-ssa-ccp.c b/contrib/gcc/tree-ssa-ccp.c
index 6e74f35..e64d80b 100644
--- a/contrib/gcc/tree-ssa-ccp.c
+++ b/contrib/gcc/tree-ssa-ccp.c
@@ -1621,9 +1621,7 @@ maybe_fold_offset_to_array_ref (tree base, tree offset, tree orig_type)
if (!integer_zerop (elt_offset))
idx = int_const_binop (PLUS_EXPR, idx, elt_offset, 0);
- return build4 (ARRAY_REF, orig_type, base, idx, min_idx,
- size_int (tree_low_cst (elt_size, 1)
- / (TYPE_ALIGN_UNIT (elt_type))));
+ return build4 (ARRAY_REF, orig_type, base, idx, NULL_TREE, NULL_TREE);
}
diff --git a/contrib/gcc/tree-ssa-pre.c b/contrib/gcc/tree-ssa-pre.c
index 9c7b89f..ba32b3c 100644
--- a/contrib/gcc/tree-ssa-pre.c
+++ b/contrib/gcc/tree-ssa-pre.c
@@ -1076,6 +1076,7 @@ phi_translate (tree expr, value_set_t set, basic_block pred,
tree newexpr;
tree vh = get_value_handle (expr);
bool listchanged = false;
+ bool invariantarg = false;
VEC (tree, gc) *vuses = VALUE_HANDLE_VUSES (vh);
VEC (tree, gc) *tvuses;
@@ -1134,10 +1135,26 @@ phi_translate (tree expr, value_set_t set, basic_block pred,
if (newval != oldval)
{
listchanged = true;
+ invariantarg |= is_gimple_min_invariant (newval);
TREE_VALUE (newwalker) = get_value_handle (newval);
}
}
}
+
+ /* In case of new invariant args we might try to fold the call
+ again. */
+ if (invariantarg)
+ {
+ tree tmp = fold_ternary (CALL_EXPR, TREE_TYPE (expr),
+ newop0, newarglist, newop2);
+ if (tmp)
+ {
+ STRIP_TYPE_NOPS (tmp);
+ if (is_gimple_min_invariant (tmp))
+ return tmp;
+ }
+ }
+
if (listchanged)
vn_lookup_or_add (newarglist, NULL);
OpenPOWER on IntegriCloud