public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kyrill Tkachov <kyrylo.tkachov@arm.com>
To: Evandro Menezes <e.menezes@samsung.com>,
	 GCC Patches <gcc-patches@gcc.gnu.org>,
	Marcus Shawcroft <Marcus.Shawcroft@arm.com>,
	 James Greenhalgh <james.greenhalgh@arm.com>,
	Andrew Pinski <pinskia@gmail.com>,
	 Benedikt Huber <benedikt.huber@theobroma-systems.com>,
	philipp.tomsich@theobroma-systems.com
Subject: Re: [AArch64] Emit square root using the Newton series
Date: Wed, 09 Dec 2015 17:03:00 -0000	[thread overview]
Message-ID: <56685EBD.5040401@arm.com> (raw)
In-Reply-To: <56685DF2.4040306@samsung.com>


On 09/12/15 16:59, Evandro Menezes wrote:
> On 12/09/2015 10:52 AM, Kyrill Tkachov wrote:
>> Hi Evandro,
>>
>> On 08/12/15 21:35, Evandro Menezes wrote:
>>> Emit square root using the Newton series
>>>
>>>    2015-12-03  Evandro Menezes  <e.menezes@samsung.com>
>>>
>>>    gcc/
>>>             * config/aarch64/aarch64-protos.h (aarch64_emit_swsqrt):
>>>    Declare new
>>>             function.
>>>             * config/aarch64/aarch64-simd.md (sqrt<mode>2): New
>>>    expansion and
>>>             insn definitions.
>>>             * config/aarch64/aarch64-tuning-flags.def
>>>             (AARCH64_EXTRA_TUNE_FAST_SQRT): New tuning macro.
>>>             * config/aarch64/aarch64.c (aarch64_emit_swsqrt): Define
>>>    new function.
>>>             * config/aarch64/aarch64.md (sqrt<mode>2): New expansion
>>>    and insn
>>>             definitions.
>>>             * config/aarch64/aarch64.opt (mlow-precision-recip-sqrt):
>>>    Expand option
>>>             description.
>>>             * doc/invoke.texi (mlow-precision-recip-sqrt): Likewise.
>>>
>>> This patch extends the patch that added support for implementing x^-1/2 using the Newton series by adding support for x^1/2 as well.
>>>
>>> Is it OK at this point of stage 3?
>>>
>>
>> A comment on the patch itself from me...
>>
>> diff --git a/gcc/config/aarch64/aarch64-tuning-flags.def b/gcc/config/aarch64/aarch64-tuning-flags.def
>> index 6f7dbce..11c6c9a 100644
>> --- a/gcc/config/aarch64/aarch64-tuning-flags.def
>> +++ b/gcc/config/aarch64/aarch64-tuning-flags.def
>> @@ -30,4 +30,4 @@
>>
>>  AARCH64_EXTRA_TUNING_OPTION ("rename_fma_regs", RENAME_FMA_REGS)
>>  AARCH64_EXTRA_TUNING_OPTION ("recip_sqrt", RECIP_SQRT)
>> -
>> +AARCH64_EXTRA_TUNING_OPTION ("fast_sqrt", FAST_SQRT)
>>
>> That seems like a misleading name to me.
>> If we're doing this, that means that the sqrt instruction is not faster
>> than doing the inverse sqrt estimation followed by a multiply.
>> I think a name like "synth_sqrt" or "estimate_sqrt" or something along those lines
>> is more appropriate.
>
> Unfortunately, this is the case on Exynos M1: the series is faster than the instruction. :-(  So, other targets when this is also true, using the "fast_sqrt" option might make sense.
>

Sure, but the way your patch is written, we will emit the series when "fast_sqrt" is set, rather
than the other way around, unless I'm misreading the logic in:

diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md
index 030a101..f6d2da4 100644
--- a/gcc/config/aarch64/aarch64-simd.md
+++ b/gcc/config/aarch64/aarch64-simd.md
@@ -4280,7 +4280,23 @@
  
  ;; sqrt
  
-(define_insn "sqrt<mode>2"
+(define_expand "sqrt<mode>2"
+  [(set (match_operand:VDQF 0 "register_operand")
+	(sqrt:VDQF (match_operand:VDQF 1 "register_operand")))]
+  "TARGET_SIMD"
+{
+  if ((AARCH64_EXTRA_TUNE_FAST_SQRT & aarch64_tune_params.extra_tuning_flags)
+      && !optimize_function_for_size_p (cfun)
+      && flag_finite_math_only
+      && !flag_trapping_math
+      && flag_unsafe_math_optimizations)
+    {
+      aarch64_emit_swsqrt (operands[0], operands[1]);
+      DONE;
+    }
+})


Thanks,
Kyrill


  reply	other threads:[~2015-12-09 17:03 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-08 21:35 Evandro Menezes
2015-12-09 14:05 ` Marcus Shawcroft
2015-12-09 16:31   ` Evandro Menezes
2015-12-09 16:52 ` Kyrill Tkachov
2015-12-09 16:59   ` Evandro Menezes
2015-12-09 17:03     ` Kyrill Tkachov [this message]
2015-12-09 17:16       ` Kyrill Tkachov
2015-12-09 18:50         ` Evandro Menezes
2015-12-10 10:30           ` Kyrill Tkachov
2016-02-23  0:50             ` Evandro Menezes
2016-02-26 15:00               ` James Greenhalgh
2016-02-26 23:42                 ` Evandro Menezes
2016-02-26 23:46                   ` Evandro Menezes
2016-02-16 20:56 ` Evandro Menezes
2016-03-04  0:22   ` Evandro Menezes
2016-03-08 22:08     ` Evandro Menezes
2016-03-08 22:18       ` Evandro Menezes
2016-03-08 22:20         ` Evandro Menezes
2016-03-16 19:45       ` Evandro Menezes
2016-03-17 14:55         ` James Greenhalgh
2016-03-17 16:25           ` Evandro Menezes
     [not found] <AM3PR08MB00886499882773F3C8B9F71D83B30@AM3PR08MB0088.eurprd08.prod.outlook.com>
     [not found] ` <011d01d17a26$31b3ade0$951b09a0$@samsung.com>
2016-03-10 16:52   ` Wilco Dijkstra
2016-03-10 16:58     ` Evandro Menezes
2016-03-10 19:10       ` Wilco Dijkstra
2016-03-10 22:15         ` Evandro Menezes
2016-03-11  1:06           ` Wilco Dijkstra
2016-03-14 16:39             ` Evandro Menezes
2016-03-14 19:13               ` Wilco Dijkstra
2016-03-16 21:44             ` Evandro Menezes
2016-03-17 22:50 Evandro Menezes
2016-03-24 20:30 ` [AArch64] " Evandro Menezes
2016-04-01 22:45   ` Evandro Menezes
2016-04-04 16:32     ` Evandro Menezes
     [not found]       ` <DB3PR08MB008902F0F0AFA3B1F1C91511839E0@DB3PR08MB0089.eurprd08.prod.outlook.com>
2016-04-05 22:30         ` Evandro Menezes
2016-04-12 18:15           ` Evandro Menezes
2016-04-21 18:44             ` Evandro Menezes
2016-04-27 14:24             ` James Greenhalgh
2016-04-27 15:45               ` Evandro Menezes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56685EBD.5040401@arm.com \
    --to=kyrylo.tkachov@arm.com \
    --cc=Marcus.Shawcroft@arm.com \
    --cc=benedikt.huber@theobroma-systems.com \
    --cc=e.menezes@samsung.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=james.greenhalgh@arm.com \
    --cc=philipp.tomsich@theobroma-systems.com \
    --cc=pinskia@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).