summaryrefslogtreecommitdiff
path: root/gcc/rtlanal.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2001-05-17 21:21:21 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2001-05-17 21:21:21 +0000
commit09f800b9baea8ff279f12fc8dd31e75620156cd4 (patch)
tree6be18b336d723f66b33f5327a8908ec4da42a48e /gcc/rtlanal.c
parentf760707b3708c8c4848cae367cce7a970fc266cd (diff)
downloadgcc-09f800b9baea8ff279f12fc8dd31e75620156cd4.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@42224 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/rtlanal.c')
-rw-r--r--gcc/rtlanal.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index b0e2f4eeb0f..af0f81fc817 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. */