From 467719fbf259d4c8f01cd370b1de53043497024e Mon Sep 17 00:00:00 2001 From: Prathamesh Kulkarni Date: Sat, 6 Aug 2016 05:04:07 +0000 Subject: [PATCH] match.pd ((intptr_t) x eq/ne CST to x eq/ne (typeof x) cst): Disable transform if operand's type is pointer to function or method. 2016-08-06 Prathamesh Kulkarni * match.pd ((intptr_t) x eq/ne CST to x eq/ne (typeof x) cst): Disable transform if operand's type is pointer to function or method. From-SVN: r239190 --- gcc/ChangeLog | 5 +++++ gcc/match.pd | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f6a62d1ffc1..c72eb5ff5ec 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-08-06 Prathamesh Kulkarni + + * match.pd ((intptr_t) x eq/ne CST to x eq/ne (typeof x) cst): Disable + transform if operand's type is pointer to function or method. + 2016-08-05 Patrick Palka PR tree-optimization/18046 diff --git a/gcc/match.pd b/gcc/match.pd index 2380d90d5db..ac7cfff0ae2 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -2528,12 +2528,18 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) { neeq == EQ_EXPR ? boolean_false_node : boolean_true_node; }))) /* PR70920: Transform (intptr_t)x eq/ne CST to x eq/ne (typeof x) CST. - and (typeof ptr_cst) x eq/ne ptr_cst to x eq/ne (typeof x) CST */ + and (typeof ptr_cst) x eq/ne ptr_cst to x eq/ne (typeof x) CST. + Disable the transform if either operand is pointer to function. + This broke pr22051-2.c for arm where function pointer + canonicalizaion is not wanted. */ + (for cmp (ne eq) (simplify (cmp (convert @0) INTEGER_CST@1) - (if ((POINTER_TYPE_P (TREE_TYPE (@0)) && INTEGRAL_TYPE_P (TREE_TYPE (@1))) - || (INTEGRAL_TYPE_P (TREE_TYPE (@0)) && POINTER_TYPE_P (TREE_TYPE (@1)))) + (if ((POINTER_TYPE_P (TREE_TYPE (@0)) && !FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@0))) + && INTEGRAL_TYPE_P (TREE_TYPE (@1))) + || (INTEGRAL_TYPE_P (TREE_TYPE (@0)) && POINTER_TYPE_P (TREE_TYPE (@1)) + && !FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@1))))) (cmp @0 (convert @1))))) /* Non-equality compare simplifications from fold_binary */ -- 2.30.2