aboutsummaryrefslogtreecommitdiff
path: root/contrib/gcc/fold-const.c
diff options
context:
space:
mode:
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 37d99f89d0ef..1aadd300a9b8 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));