aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/riscv/pr114512.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.target/riscv/pr114512.c')
-rw-r--r--gcc/testsuite/gcc.target/riscv/pr114512.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/riscv/pr114512.c b/gcc/testsuite/gcc.target/riscv/pr114512.c
new file mode 100644
index 0000000..205071c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr114512.c
@@ -0,0 +1,109 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcb -mabi=lp64d" { target { rv64 } } } */
+/* { dg-options "-march=rv32gcb -mabi=ilp32" { target { rv32 } } } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */
+
+/* We need to adjust the constant so this works for rv32 and rv64. */
+#if __riscv_xlen == 32
+#define ONE 1U
+#define MASK 0x1f
+typedef unsigned int utype;
+#else
+#define ONE 1ULL
+#define MASK 0x3f
+typedef unsigned long utype;
+#endif
+
+
+_Bool my_isxdigit_1(unsigned char ch) {
+ utype mask1 = 0x03FF007E;
+ if (!((mask1 >> (ch & MASK)) & 1))
+ return 0;
+
+ return 1;
+}
+
+_Bool my_isxdigit_1a(unsigned char ch) {
+ utype mask2 = 0x58;
+ if (!((mask2 >> (ch >> 4)) & 1))
+ return 0;
+
+ return 1;
+}
+
+_Bool my_isxdigit_2(unsigned char ch) {
+ utype mask1 = 0x03FF007E;
+ if (!(mask1 & (ONE << (ch & MASK))))
+ return 0;
+
+ return 1;
+}
+
+_Bool my_isxdigit_2a(unsigned char ch) {
+ utype mask2 = 0x58;
+ if (!(mask2 & (ONE << (ch >> 4))))
+ return 0;
+
+ return 1;
+}
+
+_Bool my_isxdigit_3(unsigned char ch) {
+ utype mask1 = 0x7E00FFC0;
+ if (!((mask1 << (MASK - (ch & MASK))) >> MASK))
+ return 0;
+
+ return 1;
+}
+
+_Bool my_isxdigit_3a(unsigned char ch) {
+ utype mask2 = 0x7E00FFC0;
+ if (!((mask2 << (MASK - ((ch >> 4) & MASK))) >> MASK))
+ return 0;
+
+ return 1;
+}
+
+_Bool my_isxdigit_1_parm(unsigned char ch, utype mask1) {
+ if (!((mask1 >> (ch & MASK)) & 1))
+ return 0;
+
+ return 1;
+}
+
+_Bool my_isxdigit_1a_parm(unsigned char ch, utype mask2) {
+ if (!((mask2 >> (ch >> 4)) & 1))
+ return 0;
+
+ return 1;
+}
+
+_Bool my_isxdigit_2_parm(unsigned char ch, utype mask1) {
+ if (!(mask1 & (ONE << (ch & MASK))))
+ return 0;
+
+ return 1;
+}
+
+_Bool my_isxdigit_2a_parm(unsigned char ch, utype mask2) {
+ if (!(mask2 & (ONE << (ch >> 4))))
+ return 0;
+
+ return 1;
+}
+
+_Bool my_isxdigit_3_parm(unsigned char ch, utype mask1) {
+ if (!((mask1 << (MASK - (ch & MASK))) >> MASK))
+ return 0;
+
+ return 1;
+}
+
+_Bool my_isxdigit_3a_parm(unsigned char ch, utype mask2) {
+ if (!((mask2 << (MASK - ((ch >> 4) & MASK))) >> MASK))
+ return 0;
+
+ return 1;
+}
+
+/* Each test should generate a single bext. */
+/* { dg-final { scan-assembler-times "bext\t" 12 } } */