Re: fix fallout of pr22051-2.c on arm

2016-08-05 Thread Richard Biener
On Fri, 5 Aug 2016, Prathamesh Kulkarni wrote:

> On 4 August 2016 at 12:39, Richard Biener  wrote:
> > On Thu, 4 Aug 2016, Prathamesh Kulkarni wrote:
> >
> >> Hi,
> >> The attached patch fixes pr22051-2.c which regressed due to
> >> r238754. Matthew, could you please confirm if this patch fixes the
> >> test-case for you ?
> >>
> >> Bootstrapped and tested on x86_64-unknown-linux-gnu.
> >> Cross tested on arm*-*-*.
> >> OK for trunk ?
> >
> > Note that if function pointer types are really the issue then
> > you also need to handle METHOD_TYPE, thus sth like
> >
> >   && ! FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@0))
> >
> > please also add a comment for this non-obvious thing.  I believe
> > we should simply apply function pointer canonicalization for
> > comparisons early during gimplification - exposing this target
> > detail only during RTL expansion makes generic optimization hard.
> >
> > Ok with those changes.
> Is the attached version OK ?

Ok.

Richard.

> Bootstrapped on x86_64-unknown-linux-gnu, cross-tested on arm*-*-*.
> 
> Thanks,
> Prathamesh
> >
> > Thanks,
> > Richard.
> 


Re: fix fallout of pr22051-2.c on arm

2016-08-04 Thread Prathamesh Kulkarni
On 4 August 2016 at 12:39, Richard Biener  wrote:
> On Thu, 4 Aug 2016, Prathamesh Kulkarni wrote:
>
>> Hi,
>> The attached patch fixes pr22051-2.c which regressed due to
>> r238754. Matthew, could you please confirm if this patch fixes the
>> test-case for you ?
>>
>> Bootstrapped and tested on x86_64-unknown-linux-gnu.
>> Cross tested on arm*-*-*.
>> OK for trunk ?
>
> Note that if function pointer types are really the issue then
> you also need to handle METHOD_TYPE, thus sth like
>
>   && ! FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@0))
>
> please also add a comment for this non-obvious thing.  I believe
> we should simply apply function pointer canonicalization for
> comparisons early during gimplification - exposing this target
> detail only during RTL expansion makes generic optimization hard.
>
> Ok with those changes.
Is the attached version OK ?
Bootstrapped on x86_64-unknown-linux-gnu, cross-tested on arm*-*-*.

Thanks,
Prathamesh
>
> Thanks,
> Richard.
2016-08-05  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.

diff --git a/gcc/match.pd b/gcc/match.pd
index 2380d90..ac7cfff 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  */


Re: fix fallout of pr22051-2.c on arm

2016-08-04 Thread Matthew Wahab

On 03/08/16 23:08, Prathamesh Kulkarni wrote:

Hi,
The attached patch fixes pr22051-2.c which regressed due to
r238754. Matthew, could you please confirm if this patch fixes the
test-case for you ?



Confirmed. (Tested with arm-none-linux-gnueabihf.)

Thanks
Matthew


Re: fix fallout of pr22051-2.c on arm

2016-08-04 Thread Richard Biener
On Thu, 4 Aug 2016, Prathamesh Kulkarni wrote:

> Hi,
> The attached patch fixes pr22051-2.c which regressed due to
> r238754. Matthew, could you please confirm if this patch fixes the
> test-case for you ?
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu.
> Cross tested on arm*-*-*.
> OK for trunk ?

Note that if function pointer types are really the issue then
you also need to handle METHOD_TYPE, thus sth like

  && ! FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@0))

please also add a comment for this non-obvious thing.  I believe
we should simply apply function pointer canonicalization for
comparisons early during gimplification - exposing this target
detail only during RTL expansion makes generic optimization hard.

Ok with those changes.

Thanks,
Richard.


fix fallout of pr22051-2.c on arm

2016-08-03 Thread Prathamesh Kulkarni
Hi,
The attached patch fixes pr22051-2.c which regressed due to
r238754. Matthew, could you please confirm if this patch fixes the
test-case for you ?

Bootstrapped and tested on x86_64-unknown-linux-gnu.
Cross tested on arm*-*-*.
OK for trunk ?

Thanks,
Prathamesh
2016-08-04  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.

diff --git a/gcc/match.pd b/gcc/match.pd
index 2380d90..9b97aac 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -2532,8 +2532,10 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 (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)) && !FUNCTION_POINTER_TYPE_P (TREE_TYPE 
(@0))
+   && INTEGRAL_TYPE_P (TREE_TYPE (@1)))
+  || (INTEGRAL_TYPE_P (TREE_TYPE (@0)) && POINTER_TYPE_P (TREE_TYPE (@1))
+ && !FUNCTION_POINTER_TYPE_P (TREE_TYPE (@1
(cmp @0 (convert @1)
 
 /* Non-equality compare simplifications from fold_binary  */