public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR70985
@ 2016-05-09  9:31 Richard Biener
  2019-12-14  5:29 ` Andrew Pinski
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2016-05-09  9:31 UTC (permalink / raw)
  To: gcc-patches


I am testing the following followup to my BIT_FIELD_REF simplification
changes which resolve issues when applying to memory BIT_FIELD_REFs.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Richard.

2016-05-09  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/70985
	* match.pd (BIT_FIELD_REF -> (type)): Disable on GIMPLE when
	op0 isn't a gimple register.

	* gcc.dg/torture/pr70985.c: New testcase.

Index: gcc/match.pd
===================================================================
*** gcc/match.pd	(revision 236021)
--- gcc/match.pd	(working copy)
*************** DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
*** 3244,3249 ****
--- 3244,3251 ----
       (view_convert (imagpart @0)))))
    (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
         && INTEGRAL_TYPE_P (type)
+        /* On GIMPLE this should only apply to register arguments.  */
+        && (! GIMPLE || is_gimple_reg (@0))
         /* A bit-field-ref that referenced the full argument can be stripped.  */
         && ((compare_tree_int (@1, TYPE_PRECISION (TREE_TYPE (@0))) == 0
  	    && integer_zerop (@2))
Index: gcc/testsuite/gcc.dg/torture/pr70985.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr70985.c	(revision 0)
--- gcc/testsuite/gcc.dg/torture/pr70985.c	(working copy)
***************
*** 0 ****
--- 1,28 ----
+ /* { dg-do compile } */
+ /* { dg-require-effective-target int32plus } */
+ 
+ struct
+ {
+   int f0:24;
+ } a, c, d;
+ 
+ int b;
+ 
+ int
+ fn1 ()
+ {
+   return 0;
+ }
+ 
+ void
+ fn2 ()
+ {
+   int e;
+   if (b) 
+     for (; e;)
+       {
+ 	d = c;
+ 	if (fn1 (b))
+ 	  b = a.f0;
+       }
+ }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix PR70985
  2016-05-09  9:31 [PATCH] Fix PR70985 Richard Biener
@ 2019-12-14  5:29 ` Andrew Pinski
  2019-12-14  7:47   ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Pinski @ 2019-12-14  5:29 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches

On Mon, May 9, 2016 at 2:32 AM Richard Biener <rguenther@suse.de> wrote:
>
>
> I am testing the following followup to my BIT_FIELD_REF simplification
> changes which resolve issues when applying to memory BIT_FIELD_REFs.
>
> Bootstrap and regtest running on x86_64-unknown-linux-gnu.

My question is not directly related to this patch but is partly related.
While I was working on lowering bit-field access patch, I ran into a
problem where I am building the lhs, I use fold_build3 to build the
BIT_FIELD_REF and we get a convert expression from it.
Should we be using a fold_build3 for the BIT_FIELD_REF that will be
used on the lhs or should we just disable this optimization for non
GIMPLE?
The testcases where I ran into the issue are the ones which I added
back in October; gcc.c-torture/compile/20191015-1.c and
gcc.c-torture/compile/20191015-2.c.  I added them so when I submit the
patch for lowering for GCC 11, we don't regress (there was no testcase
beforehand).

Thanks,
Andrew Pinski

>
> Richard.
>
> 2016-05-09  Richard Biener  <rguenther@suse.de>
>
>         PR tree-optimization/70985
>         * match.pd (BIT_FIELD_REF -> (type)): Disable on GIMPLE when
>         op0 isn't a gimple register.
>
>         * gcc.dg/torture/pr70985.c: New testcase.
>
> Index: gcc/match.pd
> ===================================================================
> *** gcc/match.pd        (revision 236021)
> --- gcc/match.pd        (working copy)
> *************** DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
> *** 3244,3249 ****
> --- 3244,3251 ----
>        (view_convert (imagpart @0)))))
>     (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
>          && INTEGRAL_TYPE_P (type)
> +        /* On GIMPLE this should only apply to register arguments.  */
> +        && (! GIMPLE || is_gimple_reg (@0))
>          /* A bit-field-ref that referenced the full argument can be stripped.  */
>          && ((compare_tree_int (@1, TYPE_PRECISION (TREE_TYPE (@0))) == 0
>             && integer_zerop (@2))
> Index: gcc/testsuite/gcc.dg/torture/pr70985.c
> ===================================================================
> *** gcc/testsuite/gcc.dg/torture/pr70985.c      (revision 0)
> --- gcc/testsuite/gcc.dg/torture/pr70985.c      (working copy)
> ***************
> *** 0 ****
> --- 1,28 ----
> + /* { dg-do compile } */
> + /* { dg-require-effective-target int32plus } */
> +
> + struct
> + {
> +   int f0:24;
> + } a, c, d;
> +
> + int b;
> +
> + int
> + fn1 ()
> + {
> +   return 0;
> + }
> +
> + void
> + fn2 ()
> + {
> +   int e;
> +   if (b)
> +     for (; e;)
> +       {
> +       d = c;
> +       if (fn1 (b))
> +         b = a.f0;
> +       }
> + }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix PR70985
  2019-12-14  5:29 ` Andrew Pinski
@ 2019-12-14  7:47   ` Richard Biener
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2019-12-14  7:47 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: GCC Patches

On December 14, 2019 6:28:48 AM GMT+01:00, Andrew Pinski <pinskia@gmail.com> wrote:
>On Mon, May 9, 2016 at 2:32 AM Richard Biener <rguenther@suse.de>
>wrote:
>>
>>
>> I am testing the following followup to my BIT_FIELD_REF
>simplification
>> changes which resolve issues when applying to memory BIT_FIELD_REFs.
>>
>> Bootstrap and regtest running on x86_64-unknown-linux-gnu.
>
>My question is not directly related to this patch but is partly
>related.
>While I was working on lowering bit-field access patch, I ran into a
>problem where I am building the lhs, I use fold_build3 to build the
>BIT_FIELD_REF and we get a convert expression from it.
>Should we be using a fold_build3 for the BIT_FIELD_REF that will be
>used on the lhs or should we just disable this optimization for non
>GIMPLE?
>The testcases where I ran into the issue are the ones which I added
>back in October; gcc.c-torture/compile/20191015-1.c and
>gcc.c-torture/compile/20191015-2.c.  I added them so when I submit the
>patch for lowering for GCC 11, we don't regress (there was no testcase
>beforehand).

You should never apply fold_* to where you require an lvalue. 

Richard. 

>Thanks,
>Andrew Pinski
>
>>
>> Richard.
>>
>> 2016-05-09  Richard Biener  <rguenther@suse.de>
>>
>>         PR tree-optimization/70985
>>         * match.pd (BIT_FIELD_REF -> (type)): Disable on GIMPLE when
>>         op0 isn't a gimple register.
>>
>>         * gcc.dg/torture/pr70985.c: New testcase.
>>
>> Index: gcc/match.pd
>> ===================================================================
>> *** gcc/match.pd        (revision 236021)
>> --- gcc/match.pd        (working copy)
>> *************** DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
>> *** 3244,3249 ****
>> --- 3244,3251 ----
>>        (view_convert (imagpart @0)))))
>>     (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
>>          && INTEGRAL_TYPE_P (type)
>> +        /* On GIMPLE this should only apply to register arguments. 
>*/
>> +        && (! GIMPLE || is_gimple_reg (@0))
>>          /* A bit-field-ref that referenced the full argument can be
>stripped.  */
>>          && ((compare_tree_int (@1, TYPE_PRECISION (TREE_TYPE (@0)))
>== 0
>>             && integer_zerop (@2))
>> Index: gcc/testsuite/gcc.dg/torture/pr70985.c
>> ===================================================================
>> *** gcc/testsuite/gcc.dg/torture/pr70985.c      (revision 0)
>> --- gcc/testsuite/gcc.dg/torture/pr70985.c      (working copy)
>> ***************
>> *** 0 ****
>> --- 1,28 ----
>> + /* { dg-do compile } */
>> + /* { dg-require-effective-target int32plus } */
>> +
>> + struct
>> + {
>> +   int f0:24;
>> + } a, c, d;
>> +
>> + int b;
>> +
>> + int
>> + fn1 ()
>> + {
>> +   return 0;
>> + }
>> +
>> + void
>> + fn2 ()
>> + {
>> +   int e;
>> +   if (b)
>> +     for (; e;)
>> +       {
>> +       d = c;
>> +       if (fn1 (b))
>> +         b = a.f0;
>> +       }
>> + }

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-14  7:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-09  9:31 [PATCH] Fix PR70985 Richard Biener
2019-12-14  5:29 ` Andrew Pinski
2019-12-14  7:47   ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).