Commit 2c5bfdf7 by Adam Nemet Committed by Adam Nemet

re PR middle-end/33699 (missing optimization on const addr area store)

	PR middle-end/33699
	* target.h (struct gcc_target): Fix indentation.  Add
	const_anchor.
	* target-def.h (TARGET_CONST_ANCHOR): New macro.
	(TARGET_INITIALIZER): Use it.
	* cse.c (CHEAPER): Move it up to the other macros.
	(insert): Rename this ...
	(insert_with_costs): ... to this.  Add cost parameters.  Update
	function comment.
	(insert): New function.  Call insert_with_costs.
	(compute_const_anchors, insert_const_anchor, insert_const_anchors,
	find_reg_offset_for_const, try_const_anchors): New functions.
	(cse_insn): Call try_const_anchors.  Adjust cost of src_related
	when using a const-anchor.  Call insert_const_anchors.
	* config/mips/mips.c (mips_set_mips16_mode): Set
	targetm.const_anchor.
	* doc/tm.texi (Misc): Document TARGET_CONST_ANCHOR.

testsuite/
	* gcc.target/mips/const-anchor-1.c: New test.
	* gcc.target/mips/const-anchor-2.c: New test.

From-SVN: r147944
parent 51fb7760
2009-05-28 Adam Nemet <anemet@caviumnetworks.com>
PR middle-end/33699
* target.h (struct gcc_target): Fix indentation. Add
const_anchor.
* target-def.h (TARGET_CONST_ANCHOR): New macro.
(TARGET_INITIALIZER): Use it.
* cse.c (CHEAPER): Move it up to the other macros.
(insert): Rename this ...
(insert_with_costs): ... to this. Add cost parameters. Update
function comment.
(insert): New function. Call insert_with_costs.
(compute_const_anchors, insert_const_anchor, insert_const_anchors,
find_reg_offset_for_const, try_const_anchors): New functions.
(cse_insn): Call try_const_anchors. Adjust cost of src_related
when using a const-anchor. Call insert_const_anchors.
* config/mips/mips.c (mips_set_mips16_mode): Set
targetm.const_anchor.
* doc/tm.texi (Misc): Document TARGET_CONST_ANCHOR.
2009-05-28 Alexandre Oliva <aoliva@redhat.com>
* tree-inline.c (remap_decls): Enable nonlocalized variables
......
......@@ -13928,6 +13928,8 @@ mips_set_mips16_mode (int mips16_p)
targetm.min_anchor_offset = 0;
targetm.max_anchor_offset = 127;
targetm.const_anchor = 0;
if (flag_pic && !TARGET_OLDABI)
sorry ("MIPS16 PIC for ABIs other than o32 and o64");
......@@ -13955,6 +13957,8 @@ mips_set_mips16_mode (int mips16_p)
targetm.min_anchor_offset = -32768;
targetm.max_anchor_offset = 32767;
targetm.const_anchor = 0x8000;
}
/* (Re)initialize MIPS target internals for new ISA. */
......
......@@ -10852,3 +10852,21 @@ cannot safely move arguments from the registers in which they are passed
to the stack. Therefore, this hook should return true in general, but
false for naked functions. The default implementation always returns true.
@end deftypefn
@deftypevr {Target Hook} {unsigned HOST_WIDE_INT} TARGET_CONST_ANCHOR
On some architectures it can take multiple instructions to synthesize
a constant. If there is another constant already in a register that
is close enough in value then it is preferable that the new constant
is computed from this register using immediate addition or
substraction. We accomplish this through CSE. Besides the value of
the constant we also add a lower and an upper constant anchor to the
available expressions. These are then queried when encountering new
constants. The anchors are computed by rounding the constant up and
down to a multiple of the value of @code{TARGET_CONST_ANCHOR}.
@code{TARGET_CONST_ANCHOR} should be the maximum positive value
accepted by immediate-add plus one. We currently assume that the
value of @code{TARGET_CONST_ANCHOR} is a power of 2. For example, on
MIPS, where add-immediate takes a 16-bit signed value,
@code{TARGET_CONST_ANCHOR} is set to @samp{0x8000}. The default value
is zero, which disables this optimization. @end deftypevr
......@@ -423,6 +423,7 @@
/* In cse.c. */
#define TARGET_ADDRESS_COST default_address_cost
#define TARGET_CONST_ANCHOR 0
/* In builtins.c. */
#define TARGET_INIT_BUILTINS hook_void_void
......@@ -922,6 +923,7 @@
TARGET_STACK_PROTECT_FAIL, \
TARGET_INVALID_WITHIN_DOLOOP, \
TARGET_VALID_DLLIMPORT_ATTRIBUTE_P, \
TARGET_CONST_ANCHOR, \
TARGET_CALLS, \
TARGET_INVALID_CONVERSION, \
TARGET_INVALID_UNARY_OP, \
......
......@@ -481,7 +481,7 @@ struct gcc_target
/* Target builtin that implements vector permute. */
tree (* builtin_vec_perm) (tree, tree*);
} vectorize;
} vectorize;
/* The initial value of target_flags. */
int default_target_flags;
......@@ -825,6 +825,10 @@ struct gcc_target
checks to handle_dll_attribute (). */
bool (* valid_dllimport_attribute_p) (const_tree decl);
/* If non-zero, align constant anchors in CSE to a multiple of this
value. */
unsigned HOST_WIDE_INT const_anchor;
/* Functions relating to calls - argument passing, returns, etc. */
struct calls {
bool (*promote_function_args) (const_tree fntype);
......
2009-05-28 Adam Nemet <anemet@caviumnetworks.com>
PR middle-end/33699
* gcc.target/mips/const-anchor-1.c: New test.
* gcc.target/mips/const-anchor-2.c: New test.
2009-05-27 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/initlist15.C: New.
......
/* Derive a constant (0x1233ffff) from an intermediate value
(0x1234000) used to build another constant. */
/* { dg-options "-O" } */
/* { dg-final { scan-assembler-not "0x12330000|305332224" } } */
/* { dg-final { scan-assembler "addiu\t\\\$5,\\\$\[0-9\]*,-1" } } */
NOMIPS16 void f ()
{
g (0x12340001, 0x1233ffff);
}
/* Derive a constant (0x30001) from another constant. */
/* { dg-options "-O" } */
/* { dg-final { scan-assembler-not "0x300000|196608" } } */
/* { dg-final { scan-assembler "addiu\t\\\$5,\\\$\[0-9\]*,32763" } } */
NOMIPS16 void f ()
{
g (0x28006, 0x30001);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment