diff mbox

[mid-end] Fix single use requirement for xorsign (x * copysign (1, y))

Message ID 20170822162720.GA30641@arm.com
State New
Headers show

Commit Message

Tamar Christina Aug. 22, 2017, 4:27 p.m. UTC
Hi All,

This patch fixes the placement of the single-use requirement for xorsign.

on `x = a * copysign (1, b)` the intention was that `copysign (1, b)` be
single use, and not `x`. Requiring `x` to be single use blocks transformation
where we do want it to occur.

Regtested on aarch64-none-linux-gnu and no regressions
(only target currently supporting this).

Ok for trunk?

gcc/
2017-08-22  Tamar Christina  <tamar.christina@arm.com>

	PR middle-end/19706
	* tree-ssa-math-opts.c (convert_expand_mult_copysign):
	Fix single-use check.

--

Comments

Tamar Christina Aug. 22, 2017, 4:32 p.m. UTC | #1
Sorry, forgot to add some maintainers :)
Richard Biener Aug. 23, 2017, 10:39 a.m. UTC | #2
On Tue, 22 Aug 2017, Tamar Christina wrote:

> Sorry, forgot to add some maintainers :)
> ________________________________________
> From: gcc-patches-owner@gcc.gnu.org <gcc-patches-owner@gcc.gnu.org> on behalf of Tamar Christina <tamar.christina@arm.com>
> Sent: Tuesday, August 22, 2017 5:27:23 PM
> To: gcc-patches@gcc.gnu.org
> Cc: nd; law@redhat.com
> Subject: [PATCH][GCC][mid-end] Fix single use requirement for xorsign (x * copysign (1, y))
> 
> Hi All,
> 
> This patch fixes the placement of the single-use requirement for xorsign.
> 
> on `x = a * copysign (1, b)` the intention was that `copysign (1, b)` be
> single use, and not `x`. Requiring `x` to be single use blocks transformation
> where we do want it to occur.
> 
> Regtested on aarch64-none-linux-gnu and no regressions
> (only target currently supporting this).
> 
> Ok for trunk?

Ok with re-ordering the checks -- has_single_use is cheaper than
is_copysign_call_with_1.

Thanks,
Richard.

> gcc/
> 2017-08-22  Tamar Christina  <tamar.christina@arm.com>
> 
>         PR middle-end/19706
>         * tree-ssa-math-opts.c (convert_expand_mult_copysign):
>         Fix single-use check.
> 
> --
> 
>
diff mbox

Patch

diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index 87940b6e00db0d34a472504cf70923d1d334eccb..f26d105c16145bc77dd5e3a05b13f22aff43d4d8 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -3200,21 +3200,20 @@  convert_expand_mult_copysign (gimple *stmt, gimple_stmt_iterator *gsi)
   type = TREE_TYPE (lhs);
   machine_mode mode = TYPE_MODE (type);
 
-  if (HONOR_SNANS (type) || !has_single_use (lhs))
+  if (HONOR_SNANS (type))
     return false;
 
   if (TREE_CODE (treeop0) == SSA_NAME && TREE_CODE (treeop1) == SSA_NAME)
     {
       gimple *call0 = SSA_NAME_DEF_STMT (treeop0);
-      if (!is_copysign_call_with_1 (call0))
+      if (!is_copysign_call_with_1 (call0) || !has_single_use (treeop0))
 	{
 	  call0 = SSA_NAME_DEF_STMT (treeop1);
-	  if (!is_copysign_call_with_1 (call0))
+	  if (!is_copysign_call_with_1 (call0) || !has_single_use (treeop1))
 	    return false;
 
 	  treeop1 = treeop0;
 	}
-
 	if (optab_handler (xorsign_optab, mode) == CODE_FOR_nothing)
 	  return false;