rs6000: New darn testcase (PR91481)
diff mbox series

Message ID a386a22c380a6349c3d7c41c34d32edab7c7d7b2.1566597726.git.segher@kernel.crashing.org
State New
Headers show
Series
  • rs6000: New darn testcase (PR91481)
Related show

Commit Message

Segher Boessenkool Aug. 23, 2019, 10:12 p.m. UTC
We used to implement darn with unspecs, not unspec_volatiles, which
means two darn instructions could be CSEd together.

This testcase tests it by adding together four random numbers.  If all
is well that means we get four darn instructions, because such a small
loop is unrolled fine at -O2 already.  If things go bad, combine will
combine it all to one darn and a shift left by two.

Tested on powerpc64-linux {-m32,-m64,-m32/-mpowerpc64}.  Committing to
trunk.


Segher


2019-08-22  Segher Boessenkool  <segher@kernel.crashing.org>

gcc/testsuite/
	PR target/91481
	* gcc.target/powerpc/darn-3.c: New testcase.

---
 gcc/testsuite/gcc.target/powerpc/darn-3.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/darn-3.c

Patch
diff mbox series

diff --git a/gcc/testsuite/gcc.target/powerpc/darn-3.c b/gcc/testsuite/gcc.target/powerpc/darn-3.c
new file mode 100644
index 0000000..477901f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/darn-3.c
@@ -0,0 +1,16 @@ 
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "" { powerpc*-*-aix* } } */
+/* { dg-options "-O2 -mdejagnu-cpu=power9" } */
+
+static int darn32(void) { return __builtin_darn_32(); }
+
+int four(void)
+{
+	int sum = 0;
+	int i;
+	for (i = 0; i < 4; i++)
+		sum += darn32();
+	return sum;
+}
+
+/* { dg-final { scan-assembler-times {(?n)\mdarn .*,0\M} 4 } } */