diff options
author | Jan Hubicka <jh@suse.cz> | 2001-05-17 23:21:21 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2001-05-17 21:21:21 +0000 |
commit | e5c56fd9bf8418ff01126783bcd984fb151b21a2 (patch) | |
tree | 6be18b336d723f66b33f5327a8908ec4da42a48e /gcc/rtlanal.c | |
parent | 949c5d62571446e982b85c6190af0a172d645356 (diff) | |
download | gcc-e5c56fd9bf8418ff01126783bcd984fb151b21a2.zip gcc-e5c56fd9bf8418ff01126783bcd984fb151b21a2.tar.gz gcc-e5c56fd9bf8418ff01126783bcd984fb151b21a2.tar.bz2 |
integrate.c (copy_rtx_and_substitute): Use simplify_gen_subreg.
* integrate.c (copy_rtx_and_substitute): Use simplify_gen_subreg.
(simplify_subreg): Handle complex types represented as CONCAT.
* recog.c (validate_replace_rtx_1): Properly canonicalize expression
* rtl.h (swap_commutative_operands_p): Declare.
* rtlanal.c (swap_commutative_operands_p): New.
(operand_preference): New static function.
* combine.c (combine_simplify_rtx): Use swap_commutative_operands_p.
(gen_binary): Likewise.
* optabs.c (emit_cmp_and_jump_insns, emit_conditional_move): Likewise.
* simplify-rtx.c (simplify_gen_binary,
simplify_gen_relational): Likewise.
From-SVN: r42224
Diffstat (limited to 'gcc/rtlanal.c')
-rw-r--r-- | gcc/rtlanal.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index b0e2f4e..af0f81f 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -30,6 +30,7 @@ Boston, MA 02111-1307, USA. */ static void set_of_1 PARAMS ((rtx, rtx, void *)); static void insn_dependent_p_1 PARAMS ((rtx, rtx, void *)); static int computed_jump_p_1 PARAMS ((rtx)); +static int operand_preference PARAMS ((rtx)); /* Bit flags that specify the machine subtype we are compiling for. Bits are tested using macros TARGET_... defined in the tm.h file @@ -2533,6 +2534,52 @@ regno_use_in (regno, x) return NULL_RTX; } +/* Return a value indicating whether OP, an operand of a commutative + operation, is preferred as the first or second operand. The higher + the value, the stronger the preference for being the first operand. + We use negative values to indicate a preference for the first operand + and positive values for the second operand. */ + +static int +operand_preference (op) + rtx op; +{ + /* Constants always come the second operand. Prefer "nice" constants. */ + if (GET_CODE (op) == CONST_INT) + return -4; + if (GET_CODE (op) == CONST_DOUBLE) + return -3; + if (CONSTANT_P (op)) + return -2; + + /* SUBREGs of objects should come second. */ + if (GET_CODE (op) == SUBREG + && GET_RTX_CLASS (GET_CODE (SUBREG_REG (op))) == 'o') + return -1; + + /* If only one operand is a `neg', `not', + `mult', `plus', or `minus' expression, it will be the first + operand. */ + if (GET_CODE (op) == NEG || GET_CODE (op) == NOT + || GET_CODE (op) == MULT || GET_CODE (op) == PLUS + || GET_CODE (op) == MINUS) + return 2; + + /* Complex expressions should be the first. */ + if (GET_RTX_CLASS (GET_CODE (op)) == 'o') + return 1; + return 0; +} + +/* Return 1 iff it is neccesary to swap operands of commutative operation + in order to canonicalize expression. */ + +int +swap_commutative_operands_p (x, y) + rtx x, y; +{ + return operand_preference (x) < operand_preference (y); +} /* Return 1 if X is an autoincrement side effect and the register is not the stack pointer. */ |