diff mbox

rs6000: Add testcase for shifts

Message ID 0662d2e59fb2f983e8df0a473ab939b123025b07.1435932505.git.segher@kernel.crashing.org
State New
Headers show

Commit Message

Segher Boessenkool July 3, 2015, 2:16 p.m. UTC
This new test tests that all shifts of int compile to exactly one
machine instruction, not two as in the PR (which was a problem in
combine).  Tested on powerpc64-linux, with the usual options
(-m32,-m32/-mpowerpc64,-m64,-m64/-mlra); okay for trunk?


Segher


2015-07-03  Segher Boessenkool  <segher@kernel.crashing.org>

gcc/testsuite/
	PR rtl-optimization/66706
	* gcc.target/powerpc/shift-int.c: New testcase.

---
 gcc/testsuite/gcc.target/powerpc/shift-int.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/shift-int.c

Comments

David Edelsohn July 3, 2015, 2:31 p.m. UTC | #1
On Fri, Jul 3, 2015 at 10:16 AM, Segher Boessenkool
<segher@kernel.crashing.org> wrote:
> This new test tests that all shifts of int compile to exactly one
> machine instruction, not two as in the PR (which was a problem in
> combine).  Tested on powerpc64-linux, with the usual options
> (-m32,-m32/-mpowerpc64,-m64,-m64/-mlra); okay for trunk?
>
>
> Segher
>
>
> 2015-07-03  Segher Boessenkool  <segher@kernel.crashing.org>
>
> gcc/testsuite/
>         PR rtl-optimization/66706
>         * gcc.target/powerpc/shift-int.c: New testcase.

Okay.

Thanks, David
diff mbox

Patch

diff --git a/gcc/testsuite/gcc.target/powerpc/shift-int.c b/gcc/testsuite/gcc.target/powerpc/shift-int.c
new file mode 100644
index 0000000..fe696ea
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/shift-int.c
@@ -0,0 +1,23 @@ 
+/* Check that shifts do not get unnecessary extends.
+   See PR66706 for a case where this failed.  */
+
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+/* Each function should compile to exactly two instructions.  */
+/* { dg-final { scan-assembler-times {(?n)^\s+[a-z]} 16 } } */
+/* { dg-final { scan-assembler-times {(?n)^\s+blr} 8 } } */
+
+
+typedef unsigned u;
+typedef signed s;
+
+u rot(u x, u n) { return (x << n) | (x >> (32 - n)); }
+u shl(u x, u n) { return x << n; }
+u shr(u x, u n) { return x >> n; }
+s asr(s x, u n) { return x >> n; }
+
+u roti(u x) { return (x << 23) | (x >> 9); }
+u shli(u x) { return x << 23; }
+u shri(u x) { return x >> 23; }
+s asri(s x) { return x >> 23; }