[PATCH] Fix PR70985
Richard Biener
rguenther@suse.de
Sat Dec 14 07:47:00 GMT 2019
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;
>> + }
>> + }
More information about the Gcc-patches
mailing list