From: Bernd Schmidt Date: Tue, 31 Mar 2009 15:19:33 +0000 (+0000) Subject: simplify-rtx.c (simplify_relational_operation_1): Simplify (LTU (PLUS a C) C) or... X-Git-Tag: releases/gcc-4.5.0~6999 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d1eb80cf6d7d4ef999bc3a3024fd49aab88f92b;p=thirdparty%2Fgcc.git simplify-rtx.c (simplify_relational_operation_1): Simplify (LTU (PLUS a C) C) or (LTU (PLUS a C) a) to (GEU a -C)... * simplify-rtx.c (simplify_relational_operation_1): Simplify (LTU (PLUS a C) C) or (LTU (PLUS a C) a) to (GEU a -C); likewise with GEU/LTU reversed. From-SVN: r145353 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d4686fd651be..9aeafa9eae20 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -15,6 +15,10 @@ and keep using them to simplify new expressions, while applying the same substitutions to them as to the expression. + * simplify-rtx.c (simplify_relational_operation_1): Simplify + (LTU (PLUS a C) C) or (LTU (PLUS a C) a) to (GEU a -C); likewise with + GEU/LTU reversed. + 2009-03-31 Ramana Radhakrishnan PR target/27237 diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 6fe480f5dc7e..b8b6ad81763a 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -3856,6 +3856,20 @@ simplify_relational_operation_1 (enum rtx_code code, enum machine_mode mode, } } + /* (LTU/GEU (PLUS a C) C), where C is constant, can be simplified to + (GEU/LTU a -C). Likewise for (LTU/GEU (PLUS a C) a). */ + if ((code == LTU || code == GEU) + && GET_CODE (op0) == PLUS + && GET_CODE (XEXP (op0, 1)) == CONST_INT + && (rtx_equal_p (op1, XEXP (op0, 0)) + || rtx_equal_p (op1, XEXP (op0, 1)))) + { + rtx new_cmp + = simplify_gen_unary (NEG, cmp_mode, XEXP (op0, 1), cmp_mode); + return simplify_gen_relational ((code == LTU ? GEU : LTU), mode, + cmp_mode, XEXP (op0, 0), new_cmp); + } + /* Canonicalize (LTU/GEU (PLUS a b) b) as (LTU/GEU (PLUS a b) a). */ if ((code == LTU || code == GEU) && GET_CODE (op0) == PLUS