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.
gcc/testsuite/
PR target/91481
* gcc.target/powerpc/darn-3.c: New testcase.
From-SVN: r274889
+2019-08-23 Segher Boessenkool <segher@kernel.crashing.org>
+
+ PR target/91481
+ * gcc.target/powerpc/darn-3.c: New testcase.
+
2019-08-23 Marek Polacek <polacek@redhat.com>
PR c++/79817 - attribute deprecated on namespace.
--- /dev/null
+/* { 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 } } */