This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Revision 107218 changed addressing mode generation


Revision 107218, which introduced fold_plusminus_mult_expr, changed the way we are folding certain constants.

Breakpoint 7, fold_plusminus_mult_expr (code=PLUS_EXPR, type=0xb7b0c000, arg0=0xb6b8ebd0, arg1=0xb6b8c7a8)
7389 {
(gdb) p arg0
$48 = (tree) 0xb6b8ebd0
(gdb) pt
<mult_expr 0xb6b8ebd0
type <integer_type 0xb7b0c000 long unsigned int public unsigned sizetype SI
size <integer_cst 0xb7afc444 constant invariant 32>
unit size <integer_cst 0xb7afc230 constant invariant 4>
align 32 symtab 0 alias set -1 canonical type 0xb7b16270 precision 32 min <integer_cst 0xb7afc4d0 0> max <integer_cst 0xb7afc9bc -1>>


arg 0 <bit_and_expr 0xb6b8ebac type <integer_type 0xb7b0c000 long unsigned int>

arg 0 <nop_expr 0xb69845c0 type <integer_type 0xb7b0c000 long unsigned int>
arg 0 <var_decl 0xb6b8d9f8 work.384>>
arg 1 <integer_cst 0xb723f40c constant invariant 63>> arg 1 <integer_cst 0xb7afc230 4>>
(gdb) p arg1
$49 = (tree) 0xb6b8c7a8
(gdb) pt
<integer_cst 0xb6b8c7a8 type <integer_type 0xb7b0c000 long unsigned int> constant invariant 1792>


Instead of generating a PLUS around the MULT, this falls into the last arm of the if statement (with the maybe_same code) and produces a MULT of a PLUS. This behaviour is different from what fold-const did in 4.1. In some cases, the new code causes less efficient addressing modes to be generated on the Blackfin.

I can make the problem go away with the patch below. Richard, is that maybe what you originally intended here?


Bernd -- This footer brought to you by insane German lawmakers. Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB 40368 Geschaeftsfuehrer Thomas Wessel, William A. Martin, Margaret Seif
Index: gcc-4.3/gcc/fold-const.c
===================================================================
--- gcc-4.3/gcc/fold-const.c	(revision 3231)
+++ gcc-4.3/gcc/fold-const.c	(working copy)
@@ -7445,9 +7445,11 @@ fold_plusminus_mult_expr (enum tree_code
 
   /* No identical multiplicands; see if we can find a common
      power-of-two factor in non-power-of-two multiplies.  This
-     can help in multi-dimensional array access.  */
-  else if (host_integerp (arg01, 0)
-	   && host_integerp (arg11, 0))
+     can help in multi-dimensional array access.  Don't do this
+     if one of our arguments was a constant.  */
+  else if (host_integerp (arg01, 0) && host_integerp (arg11, 0)
+	   && TREE_CODE (arg0) != INTEGER_CST
+	   && TREE_CODE (arg1) != INTEGER_CST)
     {
       HOST_WIDE_INT int01, int11, tmp;
       bool swap = false;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]