aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/vax/ffshi.c
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@linux-mips.org>2020-12-05 18:26:25 +0000
committerMaciej W. Rozycki <macro@linux-mips.org>2020-12-05 18:26:25 +0000
commitb9240a4abcd1e194dbd80460a9a7632e63fb7f49 (patch)
tree325563920c978c0f1be2eec6fcf273c8d6336810 /gcc/testsuite/gcc.target/vax/ffshi.c
parent273ffa3a6fef82738dd86522374fae69ab0e2651 (diff)
downloadgcc-b9240a4abcd1e194dbd80460a9a7632e63fb7f49.zip
gcc-b9240a4abcd1e194dbd80460a9a7632e63fb7f49.tar.gz
gcc-b9240a4abcd1e194dbd80460a9a7632e63fb7f49.tar.bz2
VAX: Actually produce QImode and HImode `ctz' operations
The middle end does not refer to `ctzqi2'/`ctzhi2' or `ffsqi2'/`ffshi2' patterns by name where `__builtin_ctz' or `__builtin_ffs' respectively is invoked for an argument of the QImode or HImode type, and instead it extends the data type before passing it to `ctzsi2' or `ffssi2'. Avoid the redundant operation and use a peephole2 to convert it to the right RTL expression that will collapse the two operations into a single machine instruction instead unless we need the extended intermediate result for another purpose. gcc/ * config/vax/builtins.md: Add a peephole2 for QImode and HImode `ctz' operations. (any_extend): New code iterator. gcc/testsuite/ * gcc.target/vax/ctzhi.c: New test. * gcc.target/vax/ctzqi.c: New test. * gcc.target/vax/ffshi.c: New test. * gcc.target/vax/ffsqi.c: New test.
Diffstat (limited to 'gcc/testsuite/gcc.target/vax/ffshi.c')
-rw-r--r--gcc/testsuite/gcc.target/vax/ffshi.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/vax/ffshi.c b/gcc/testsuite/gcc.target/vax/ffshi.c
new file mode 100644
index 0000000..db592fb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/vax/ffshi.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-rtl-peephole2" } */
+/* { dg-skip-if "code quality test" { *-*-* } { "-O0" "-O1" } { "" } } */
+
+typedef int __attribute__ ((mode (HI))) int_t;
+
+int
+ffshi (int_t *x)
+{
+ return __builtin_ffs (*x);
+}
+
+/* Expect assembly like:
+
+ ffs $0,$16,*4(%ap),%r0
+ jneq .L2
+ mnegl $1,%r0
+.L2:
+ incl %r0
+
+ */
+
+/* { dg-final { scan-rtl-dump-times "Splitting with gen_peephole2" 1 "peephole2" } } */
+/* { dg-final { scan-assembler "\tffs \\\$0,\\\$16," } } */