target-insns.def (canonicalize_funcptr_for_compare): Add.
2015-06-30 Richard Biener <rguenther@suse.de> * target-insns.def (canonicalize_funcptr_for_compare): Add. * fold-const.c (build_range_check): Replace uses of HAVE_canonicalize_funcptr_for_compare. (fold_widened_comparison): Likewise. (fold_sign_changed_comparison): Likewise. * dojump.c: Include "target.h". (do_compare_and_jump): Replace uses of HAVE_canonicalize_funcptr_for_compare and gen_canonicalize_funcptr_for_compare. * expr.c (do_store_flag): Likewise. From-SVN: r225163
This commit is contained in:
parent
4f75d60893
commit
582554e3bc
5 changed files with 23 additions and 18 deletions
|
@ -1,3 +1,16 @@
|
|||
2015-06-30 Richard Biener <rguenther@suse.de>
|
||||
|
||||
* target-insns.def (canonicalize_funcptr_for_compare): Add.
|
||||
* fold-const.c (build_range_check): Replace uses of
|
||||
HAVE_canonicalize_funcptr_for_compare.
|
||||
(fold_widened_comparison): Likewise.
|
||||
(fold_sign_changed_comparison): Likewise.
|
||||
* dojump.c: Include "target.h".
|
||||
(do_compare_and_jump): Replace uses of
|
||||
HAVE_canonicalize_funcptr_for_compare and
|
||||
gen_canonicalize_funcptr_for_compare.
|
||||
* expr.c (do_store_flag): Likewise.
|
||||
|
||||
2015-06-30 Tom de Vries <tom@codesourcery.com>
|
||||
|
||||
PR tree-optimization/66652
|
||||
|
|
|
@ -47,6 +47,7 @@ along with GCC; see the file COPYING3. If not see
|
|||
#include "predict.h"
|
||||
#include "basic-block.h"
|
||||
#include "tm_p.h"
|
||||
#include "target.h"
|
||||
|
||||
static bool prefer_and_bit_test (machine_mode, int);
|
||||
static void do_jump_by_parts_greater (tree, tree, int,
|
||||
|
@ -1204,13 +1205,12 @@ do_compare_and_jump (tree treeop0, tree treeop1, enum rtx_code signed_code,
|
|||
unsignedp = TYPE_UNSIGNED (type);
|
||||
code = unsignedp ? unsigned_code : signed_code;
|
||||
|
||||
#ifdef HAVE_canonicalize_funcptr_for_compare
|
||||
/* If function pointers need to be "canonicalized" before they can
|
||||
be reliably compared, then canonicalize them.
|
||||
Only do this if *both* sides of the comparison are function pointers.
|
||||
If one side isn't, we want a noncanonicalized comparison. See PR
|
||||
middle-end/17564. */
|
||||
if (HAVE_canonicalize_funcptr_for_compare
|
||||
if (targetm.have_canonicalize_funcptr_for_compare ()
|
||||
&& TREE_CODE (TREE_TYPE (treeop0)) == POINTER_TYPE
|
||||
&& TREE_CODE (TREE_TYPE (TREE_TYPE (treeop0)))
|
||||
== FUNCTION_TYPE
|
||||
|
@ -1221,13 +1221,12 @@ do_compare_and_jump (tree treeop0, tree treeop1, enum rtx_code signed_code,
|
|||
rtx new_op0 = gen_reg_rtx (mode);
|
||||
rtx new_op1 = gen_reg_rtx (mode);
|
||||
|
||||
emit_insn (gen_canonicalize_funcptr_for_compare (new_op0, op0));
|
||||
emit_insn (targetm.gen_canonicalize_funcptr_for_compare (new_op0, op0));
|
||||
op0 = new_op0;
|
||||
|
||||
emit_insn (gen_canonicalize_funcptr_for_compare (new_op1, op1));
|
||||
emit_insn (targetm.gen_canonicalize_funcptr_for_compare (new_op1, op1));
|
||||
op1 = new_op1;
|
||||
}
|
||||
#endif
|
||||
|
||||
do_compare_rtx_and_jump (op0, op1, code, unsignedp, mode,
|
||||
((mode == BLKmode)
|
||||
|
|
|
@ -8916,7 +8916,7 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
|
|||
return temp;
|
||||
|
||||
/* Use a compare and a jump for BLKmode comparisons, or for function
|
||||
type comparisons is HAVE_canonicalize_funcptr_for_compare. */
|
||||
type comparisons is have_canonicalize_funcptr_for_compare. */
|
||||
|
||||
if ((target == 0
|
||||
|| modifier == EXPAND_STACK_PARM
|
||||
|
@ -10920,8 +10920,7 @@ do_store_flag (sepops ops, rtx target, machine_mode mode)
|
|||
|
||||
/* We won't bother with store-flag operations involving function pointers
|
||||
when function pointers must be canonicalized before comparisons. */
|
||||
#ifdef HAVE_canonicalize_funcptr_for_compare
|
||||
if (HAVE_canonicalize_funcptr_for_compare
|
||||
if (targetm.have_canonicalize_funcptr_for_compare ()
|
||||
&& ((TREE_CODE (TREE_TYPE (arg0)) == POINTER_TYPE
|
||||
&& (TREE_CODE (TREE_TYPE (TREE_TYPE (arg0)))
|
||||
== FUNCTION_TYPE))
|
||||
|
@ -10929,7 +10928,6 @@ do_store_flag (sepops ops, rtx target, machine_mode mode)
|
|||
&& (TREE_CODE (TREE_TYPE (TREE_TYPE (arg1)))
|
||||
== FUNCTION_TYPE))))
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
STRIP_NOPS (arg0);
|
||||
STRIP_NOPS (arg1);
|
||||
|
|
|
@ -4488,14 +4488,12 @@ build_range_check (location_t loc, tree type, tree exp, int in_p,
|
|||
{
|
||||
tree etype = TREE_TYPE (exp), value;
|
||||
|
||||
#ifdef HAVE_canonicalize_funcptr_for_compare
|
||||
/* Disable this optimization for function pointer expressions
|
||||
on targets that require function pointer canonicalization. */
|
||||
if (HAVE_canonicalize_funcptr_for_compare
|
||||
if (targetm.have_canonicalize_funcptr_for_compare ()
|
||||
&& TREE_CODE (etype) == POINTER_TYPE
|
||||
&& TREE_CODE (TREE_TYPE (etype)) == FUNCTION_TYPE)
|
||||
return NULL_TREE;
|
||||
#endif
|
||||
|
||||
if (! in_p)
|
||||
{
|
||||
|
@ -6964,14 +6962,12 @@ fold_widened_comparison (location_t loc, enum tree_code code,
|
|||
return NULL_TREE;
|
||||
shorter_type = TREE_TYPE (arg0_unw);
|
||||
|
||||
#ifdef HAVE_canonicalize_funcptr_for_compare
|
||||
/* Disable this optimization if we're casting a function pointer
|
||||
type on targets that require function pointer canonicalization. */
|
||||
if (HAVE_canonicalize_funcptr_for_compare
|
||||
if (targetm.have_canonicalize_funcptr_for_compare ()
|
||||
&& TREE_CODE (shorter_type) == POINTER_TYPE
|
||||
&& TREE_CODE (TREE_TYPE (shorter_type)) == FUNCTION_TYPE)
|
||||
return NULL_TREE;
|
||||
#endif
|
||||
|
||||
if (TYPE_PRECISION (TREE_TYPE (arg0)) <= TYPE_PRECISION (shorter_type))
|
||||
return NULL_TREE;
|
||||
|
@ -7059,14 +7055,12 @@ fold_sign_changed_comparison (location_t loc, enum tree_code code, tree type,
|
|||
arg0_inner = TREE_OPERAND (arg0, 0);
|
||||
inner_type = TREE_TYPE (arg0_inner);
|
||||
|
||||
#ifdef HAVE_canonicalize_funcptr_for_compare
|
||||
/* Disable this optimization if we're casting a function pointer
|
||||
type on targets that require function pointer canonicalization. */
|
||||
if (HAVE_canonicalize_funcptr_for_compare
|
||||
if (targetm.have_canonicalize_funcptr_for_compare ()
|
||||
&& TREE_CODE (inner_type) == POINTER_TYPE
|
||||
&& TREE_CODE (TREE_TYPE (inner_type)) == FUNCTION_TYPE)
|
||||
return NULL_TREE;
|
||||
#endif
|
||||
|
||||
if (TYPE_PRECISION (inner_type) != TYPE_PRECISION (outer_type))
|
||||
return NULL_TREE;
|
||||
|
|
|
@ -32,3 +32,4 @@
|
|||
Instructions should be documented in md.texi rather than here. */
|
||||
DEF_TARGET_INSN (return, (void))
|
||||
DEF_TARGET_INSN (simple_return, (void))
|
||||
DEF_TARGET_INSN (canonicalize_funcptr_for_compare, (rtx x0, rtx x1))
|
||||
|
|
Loading…
Add table
Reference in a new issue