public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR54240
@ 2012-08-14 21:12 William J. Schmidt
  2012-08-14 21:16 ` Andrew Pinski
  2012-08-15  8:41 ` Richard Guenther
  0 siblings, 2 replies; 5+ messages in thread
From: William J. Schmidt @ 2012-08-14 21:12 UTC (permalink / raw)
  To: gcc-patches; +Cc: bergner, rguenther

Replace the once vacuously true, and now vacuously false, test for
existence of a conditional move instruction for a given mode, with one
that actually checks what it's supposed to.  Add a test case so we don't
miss such things in future.

The test is powerpc-specific.  It would be good to have an i386 version
of the test as well, if someone can help with that.

Bootstrapped and tested on powerpc64-unknown-linux-gnu with no new
regressions.  Ok for trunk?

Thanks,
Bill


gcc:

2012-08-13  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	PR tree-optimization/54240
	* tree-ssa-phiopt.c (hoist_adjacent_loads): Correct test for
	existence of conditional move with given mode.


gcc/testsuite:

2012-08-13  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	PR tree-optimization/54240
	* gcc.target/powerpc/pr54240.c: New test.


Index: gcc/testsuite/gcc.target/powerpc/pr54240.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr54240.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr54240.c	(revision 0)
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -misel -fdump-tree-phiopt-details" } */
+
+typedef struct s {
+  int v;
+  int b;
+  struct s *l;
+  struct s *r;
+} S;
+
+
+int foo(S *s)
+{
+  S *this;
+  S *next;
+
+  this = s;
+  if (this->b)
+    next = this->l;
+  else
+    next = this->r;
+
+  return next->v;
+}
+
+/* { dg-final { scan-tree-dump "Hoisting adjacent loads" "phiopt1" } } */
+/* { dg-final { cleanup-tree-dump "phiopt1" } } */
Index: gcc/tree-ssa-phiopt.c
===================================================================
--- gcc/tree-ssa-phiopt.c	(revision 190305)
+++ gcc/tree-ssa-phiopt.c	(working copy)
@@ -1843,7 +1843,8 @@ hoist_adjacent_loads (basic_block bb0, basic_block
 
       /* Check the mode of the arguments to be sure a conditional move
 	 can be generated for it.  */
-      if (!optab_handler (cmov_optab, TYPE_MODE (TREE_TYPE (arg1))))
+      if (optab_handler (movcc_optab, TYPE_MODE (TREE_TYPE (arg1)))
+	  == CODE_FOR_nothing)
 	continue;
 
       /* Both statements must be assignments whose RHS is a COMPONENT_REF.  */


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-08-15  8:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-14 21:12 [PATCH] Fix PR54240 William J. Schmidt
2012-08-14 21:16 ` Andrew Pinski
2012-08-14 21:17   ` Andrew Pinski
2012-08-14 22:07     ` William J. Schmidt
2012-08-15  8:41 ` Richard Guenther

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).