PATCH: PR optimization/9016
Mark Mitchell
mark@codesourcery.com
Fri Mar 14 16:15:00 GMT 2003
Here's a patch for PR9016, a failure to optimize floating-point
computations appropriately when inlining.
The problem is that we commit to code-shape too early; we generate:
(SET (MEM (ADDRESSOF (REG))) (CONST_DOUBLE ...))
and then cannot simplify this to:
(SET (REG) (CONST_DOUBLE ...))
so we end up dumping the constant to memory.
If we think we are setting a REG in the first place, we do:
(SET (REG) (MEM (SYMBOL_REF (.LCXX))))
which we then do a better job simplifying.
This test makes us always load CONST_DOUBLEs from the constant pool,
which gives the optimal code for the test case in the PR.
I'll check in this patch shortly, if nobody tells me it's a horrible
mistake.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2003-03-14 Mark Mitchell <mark@codesourcery.com>
PR optimization/9016
* config/i386/i386.c (ix86_expand_move): Force more CONST_DOUBLEs
into the constant pool.
Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.548
diff -c -5 -p -r1.548 i386.c
*** config/i386/i386.c 12 Mar 2003 18:06:29 -0000 1.548
--- config/i386/i386.c 14 Mar 2003 07:07:00 -0000
*************** ix86_expand_move (mode, operands)
*** 8371,8383 ****
force the value to memory now, since we'll get better code
out the back end. */
if (strict)
;
! else if (GET_CODE (op1) == CONST_DOUBLE
! && register_operand (op0, mode))
! op1 = validize_mem (force_const_mem (mode, op1));
}
}
insn = gen_rtx_SET (VOIDmode, op0, op1);
--- 8371,8391 ----
force the value to memory now, since we'll get better code
out the back end. */
if (strict)
;
! else if (GET_CODE (op1) == CONST_DOUBLE)
! {
! op1 = validize_mem (force_const_mem (mode, op1));
! if (!register_operand (op0, mode))
! {
! rtx temp = gen_reg_rtx (mode);
! emit_insn (gen_rtx_SET (VOIDmode, temp, op1));
! emit_move_insn (op0, temp);
! return;
! }
! }
}
}
insn = gen_rtx_SET (VOIDmode, op0, op1);
More information about the Gcc-patches
mailing list