aboutsummaryrefslogtreecommitdiff
path: root/gcc/dojump.c
diff options
context:
space:
mode:
authorJohn David Anglin <danglin@gcc.gnu.org>2018-09-14 23:26:12 +0000
committerJohn David Anglin <danglin@gcc.gnu.org>2018-09-14 23:26:12 +0000
commitf3743e2e32432a1d961c81097db3f755fd2dae76 (patch)
tree408d2c467782ee84c4590e65b055f6b0cb4fbc1a /gcc/dojump.c
parent07f879058339c496273c9960562c3fdad317001a (diff)
downloadgcc-f3743e2e32432a1d961c81097db3f755fd2dae76.zip
gcc-f3743e2e32432a1d961c81097db3f755fd2dae76.tar.gz
gcc-f3743e2e32432a1d961c81097db3f755fd2dae76.tar.bz2
re PR middle-end/87188 (Function pointer canonicalization optimized away)
PR middle-end/87188 * dojump.c (do_compare_and_jump): Canonicalize function pointers when one operand is a function pointer. Use POINTER_TYPE_P and FUNC_OR_METHOD_TYPE_P. * expr.c (do_store_flag): Use POINTER_TYPE_P and FUNC_OR_METHOD_TYPE_P. * fold-const.c (build_range_check): Likewise. * match.pd (simple_comparison): Likewise. From-SVN: r264336
Diffstat (limited to 'gcc/dojump.c')
-rw-r--r--gcc/dojump.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/gcc/dojump.c b/gcc/dojump.c
index 88cc96a..56c82c5f 100644
--- a/gcc/dojump.c
+++ b/gcc/dojump.c
@@ -1215,15 +1215,15 @@ do_compare_and_jump (tree treeop0, tree treeop1, enum rtx_code signed_code,
code = unsignedp ? unsigned_code : signed_code;
/* 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. */
+ be reliably compared, then canonicalize them. Canonicalize the
+ expression when one of the operands is a function pointer. This
+ handles the case where the other operand is a void pointer. See
+ PR middle-end/17564. */
if (targetm.have_canonicalize_funcptr_for_compare ()
- && POINTER_TYPE_P (TREE_TYPE (treeop0))
- && POINTER_TYPE_P (TREE_TYPE (treeop1))
- && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (treeop0)))
- && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (treeop1))))
+ && ((POINTER_TYPE_P (TREE_TYPE (treeop0))
+ && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (treeop0))))
+ || (POINTER_TYPE_P (TREE_TYPE (treeop1))
+ && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (treeop1))))))
{
rtx new_op0 = gen_reg_rtx (mode);
rtx new_op1 = gen_reg_rtx (mode);