summaryrefslogtreecommitdiff
path: root/gcc/simplify-rtx.c
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2001-06-28 00:14:23 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2001-06-28 00:14:23 +0000
commit196e03f1cff897d136a28826968dcce5acc9ac86 (patch)
tree55584ceccdd01345c451779238b56ecb878546f7 /gcc/simplify-rtx.c
parent3c52ba3b2ad0880baad1e8a038018dcb8346772b (diff)
downloadgcc-196e03f1cff897d136a28826968dcce5acc9ac86.tar.gz
* simplify-rtx.c (simplify_rtx): Canonicalize commutative expressions
by putting complex operands first and constants second. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@43621 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r--gcc/simplify-rtx.c20
1 files changed, 19 insertions, 1 deletions
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':