From 52de9b6cff32fb1da2a135b4ac03c63a3117f544 Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Wed, 18 Mar 1998 13:45:28 +0000 Subject: [PATCH] fold-const.c (operand_equal_for_comparison_p): See if equal when nop conversions are removed. Wed Mar 18 13:46:07 1998 Richard Kenner * fold-const.c (operand_equal_for_comparison_p): See if equal when nop conversions are removed. From-SVN: r18672 --- gcc/ChangeLog | 5 +++++ gcc/fold-const.c | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dd4f83cf2af..2b246554f42 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +Wed Mar 18 13:46:07 1998 Richard Kenner + + * fold-const.c (operand_equal_for_comparison_p): See if equal + when nop conversions are removed. + Wed Mar 18 13:42:01 1998 Richard Kenner * expr.c (expand_expr, case COND_EXPR): If have conditional move, diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 32f39962369..3a24e4c2df5 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -1909,7 +1909,7 @@ operand_equal_for_comparison_p (arg0, arg1, other) tree other; { int unsignedp1, unsignedpo; - tree primarg1, primother; + tree primarg0, primarg1, primother; unsigned correct_width; if (operand_equal_p (arg0, arg1, 0)) @@ -1919,6 +1919,14 @@ operand_equal_for_comparison_p (arg0, arg1, other) || ! INTEGRAL_TYPE_P (TREE_TYPE (arg1))) return 0; + /* Discard any conversions that don't change the modes of ARG0 and ARG1 + and see if the inner values are the same. This removes any + signedness comparison, which doesn't matter here. */ + primarg0 = arg0, primarg1 = arg1; + STRIP_NOPS (primarg0); STRIP_NOPS (primarg1); + if (operand_equal_p (primarg0, primarg1, 0)) + return 1; + /* Duplicate what shorten_compare does to ARG1 and see if that gives the actual comparison operand, ARG0. -- 2.30.2