From b42abad88a72de91687aca2d9d360bd4e259b84e Mon Sep 17 00:00:00 2001 From: Jeffrey A Law Date: Thu, 28 Jun 2001 00:14:23 +0000 Subject: [PATCH] simplify-rtx.c (simplify_rtx): Canonicalize commutative expressions by putting complex operands first and... * simplify-rtx.c (simplify_rtx): Canonicalize commutative expressions by putting complex operands first and constants second. From-SVN: r43621 --- gcc/ChangeLog | 5 +++++ gcc/simplify-rtx.c | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5a89256f13e..3f374681d84 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +Wed Jun 27 18:01:09 2001 Jeffrey A Law (law@cygnus.com) + + * simplify-rtx.c (simplify_rtx): Canonicalize commutative expressions + by putting complex operands first and constants second. + 2001-06-27 Gabriel Dos Reis * diagnostic.h: Add documentation. Make macros polymorphic. diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index b2123c16654..a5ef0993600 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -2520,8 +2520,26 @@ simplify_rtx (x) case '1': return simplify_unary_operation (code, mode, XEXP (x, 0), GET_MODE (XEXP (x, 0))); - case '2': case 'c': + /* Put complex operands first and constants second if commutative. */ + if (GET_RTX_CLASS (code) == 'c' + && ((CONSTANT_P (XEXP (x, 0)) && GET_CODE (XEXP (x, 1)) != CONST_INT) + || (GET_RTX_CLASS (GET_CODE (XEXP (x, 0))) == 'o' + && GET_RTX_CLASS (GET_CODE (XEXP (x, 1))) != 'o') + || (GET_CODE (XEXP (x, 0)) == SUBREG + && GET_RTX_CLASS (GET_CODE (SUBREG_REG (XEXP (x, 0)))) == 'o' + && GET_RTX_CLASS (GET_CODE (XEXP (x, 1))) != 'o'))) + { + rtx tem; + + tem = XEXP (x, 0); + XEXP (x, 0) = XEXP (x, 1); + XEXP (x, 1) = tem; + return simplify_binary_operation (code, mode, + XEXP (x, 0), XEXP (x, 1)); + } + + case '2': return simplify_binary_operation (code, mode, XEXP (x, 0), XEXP (x, 1)); case '3': -- 2.30.2