summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/fold-const.c
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 /contrib/gcc/fold-const.c
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
Diffstat (limited to 'contrib/gcc/fold-const.c')
-rw-r--r--contrib/gcc/fold-const.c8
1 files changed, 6 insertions, 2 deletions
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));
OpenPOWER on IntegriCloud