public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Richard Biener <rguenther@suse.de>, Aldy Hernandez <aldyh@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: [PATCH] phiopt: Remove unnecessary checks from spaceship_replacement [PR106506]
Date: Thu, 11 Aug 2022 10:25:42 +0200	[thread overview]
Message-ID: <YvS9BHQqbOfmSgan@tucnak> (raw)

Hi!

Those 2 checks were just me trying to be extra careful, the
(phires & 1) == phires and variants it is folded to of course make only sense
for the -1/0/1/2 result spaceship, for -1/0/1 one can just use comparisons of
phires.  We only floating point spaceship if nans aren't honored, so the
2 case is ignored, and if it is, with Aldy's changes we can simplify the
2 case away from the phi but the (phires & 1) == phires stayed.  It is safe
to treat the phires comparison as phires >= 0 even then.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2022-08-11  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/106506
	* tree-ssa-phiopt.cc (spaceship_replacement): Don't punt for
	is_cast or orig_use_lhs cases if phi_bb has 3 predecessors.

	* g++.dg/opt/pr94589-2.C: New test.

--- gcc/tree-ssa-phiopt.cc.jj	2022-08-10 09:06:53.000000000 +0200
+++ gcc/tree-ssa-phiopt.cc	2022-08-10 15:33:32.414641593 +0200
@@ -2448,8 +2448,6 @@ spaceship_replacement (basic_block cond_
 	return false;
       if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig_use_lhs))
 	return false;
-      if (EDGE_COUNT (phi_bb->preds) != 4)
-	return false;
       if (!single_imm_use (orig_use_lhs, &use_p, &use_stmt))
 	return false;
 
@@ -2467,8 +2465,6 @@ spaceship_replacement (basic_block cond_
       orig_use_lhs = gimple_assign_lhs (use_stmt);
       if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig_use_lhs))
 	return false;
-      if (EDGE_COUNT (phi_bb->preds) != 4)
-	return false;
       if (!single_imm_use (orig_use_lhs, &use_p, &use_stmt))
 	return false;
     }
--- gcc/testsuite/g++.dg/opt/pr94589-2.C.jj	2022-08-10 09:06:52.921213966 +0200
+++ gcc/testsuite/g++.dg/opt/pr94589-2.C	2022-08-10 15:45:24.599319922 +0200
@@ -1,7 +1,7 @@
 // PR tree-optimization/94589
 // { dg-do compile { target c++20 } }
 // { dg-options "-O2 -g0 -ffast-math -fdump-tree-optimized" }
-// { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) \[ij]_\[0-9]+\\(D\\)" 12 "optimized" { xfail *-*-* } } }
+// { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) \[ij]_\[0-9]+\\(D\\)" 12 "optimized" } }
 // { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) 5\\.0" 12 "optimized" } }
 
 #include <compare>

	Jakub


             reply	other threads:[~2022-08-12  9:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-11  8:25 Jakub Jelinek [this message]
2022-08-12 10:58 ` Richard Biener

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=YvS9BHQqbOfmSgan@tucnak \
    --to=jakub@redhat.com \
    --cc=aldyh@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rguenther@suse.de \
    /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).