Minor simplify_rtx improvement
law@redhat.com
law@redhat.com
Wed Jun 27 17:02:00 GMT 2001
Canonicalizing commutative expressions can result in more recognizable
patterns after simplification.
Bootstrapped on ia32-linux and PA32-hpux.
* simplify-rtx.c (simplify_rtx): Canonicalize commutative expressions
by putting complex operands first and constants second.
Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/simplify-rtx.c,v
retrieving revision 1.61
diff -c -3 -p -r1.61 simplify-rtx.c
*** simplify-rtx.c 2001/06/12 15:25:16 1.61
--- simplify-rtx.c 2001/06/27 23:49:51
*************** simplify_rtx (x)
*** 2520,2527 ****
case '1':
return simplify_unary_operation (code, mode,
XEXP (x, 0), GET_MODE (XEXP (x, 0)));
- case '2':
case 'c':
return simplify_binary_operation (code, mode, XEXP (x, 0), XEXP (x,
1));
case '3':
--- 2520,2545 ----
case '1':
return simplify_unary_operation (code, mode,
XEXP (x, 0), GET_MODE (XEXP (x, 0)));
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':
More information about the Gcc-patches
mailing list