On February 14, 2017 4:19:05 PM GMT+01:00, "Bin.Cheng" <amker.ch...@gmail.com> 
wrote:
>On Tue, Feb 14, 2017 at 2:48 PM, Richard Biener <rguent...@suse.de>
>wrote:
>>
>> The following enables final value replacement for floating point
>> expressions if -funsafe-math-optimizations is set (that's the
>> flag the reassoc pass controls similar transforms on).
>Looks to me it's kind of abusing of current implementation of SCEV for
>floating point values.  I believe it's designed only with integral
>type in mind, for example, we may need to reject float time when
>tracking scev chain via type conversion.

Note the vectorizer relies on SCEV itself here.

Richard.

>Thanks,
>bin
>>
>> Bootstrapped / tested on x86_64-unknown-linux-gnu, queued for GCC 8.
>>
>> Richard.
>>
>> 2017-02-14  Richard Biener  <rguent...@suse.de>
>>
>>         PR tree-optimization/79460
>>         * tree-scalar-evolution.c (final_value_replacement_loop):
>Also
>>         allow final value replacement of floating point expressions.
>>
>>         * gcc.dg/tree-ssa/sccp-3.c: New testcase.
>>
>> Index: gcc/tree-scalar-evolution.c
>> ===================================================================
>> --- gcc/tree-scalar-evolution.c (revision 245417)
>> +++ gcc/tree-scalar-evolution.c (working copy)
>> @@ -3718,8 +3718,10 @@ final_value_replacement_loop (struct loo
>>           continue;
>>         }
>>
>> -      if (!POINTER_TYPE_P (TREE_TYPE (def))
>> -         && !INTEGRAL_TYPE_P (TREE_TYPE (def)))
>> +      if (! (POINTER_TYPE_P (TREE_TYPE (def))
>> +            || INTEGRAL_TYPE_P (TREE_TYPE (def))
>> +            || (FLOAT_TYPE_P (TREE_TYPE (def))
>> +                && flag_unsafe_math_optimizations)))
>>         {
>>           gsi_next (&psi);
>>           continue;
>> Index: gcc/testsuite/gcc.dg/tree-ssa/sccp-3.c
>> ===================================================================
>> --- gcc/testsuite/gcc.dg/tree-ssa/sccp-3.c      (nonexistent)
>> +++ gcc/testsuite/gcc.dg/tree-ssa/sccp-3.c      (working copy)
>> @@ -0,0 +1,12 @@
>> +/* { dg-do compile } */
>> +/* { dg-options "-O2 -funsafe-math-optimizations -fdump-tree-sccp" }
>*/
>> +
>> +float f(float x[])
>> +{
>> +  float p = 1.0;
>> +  for (int i = 0; i < 200; i++)
>> +    p += 1;
>> +  return p;
>> +}
>> +
>> +/* { dg-final { scan-tree-dump "final value replacement.* =
>2.01e\\+2;" "sccp" } } */

Reply via email to