aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/riscv
diff options
context:
space:
mode:
authorJeff Law <jlaw@ventanamicro.com>2024-12-21 08:33:36 -0700
committerJeff Law <jlaw@ventanamicro.com>2024-12-21 08:35:26 -0700
commit145e462d557af537d90ef6da1391a57603c6fcf0 (patch)
tree5cdaf5b9b6e62d2b6543815a77455e5e1dd5d9c0 /gcc/testsuite/gcc.target/riscv
parent59e3abcb3625fd3d6f452a27671c8806c7a27b1b (diff)
downloadgcc-145e462d557af537d90ef6da1391a57603c6fcf0.zip
gcc-145e462d557af537d90ef6da1391a57603c6fcf0.tar.gz
gcc-145e462d557af537d90ef6da1391a57603c6fcf0.tar.bz2
[RISC-V][PR middle-end/118084] Fix brev based reflection code
The fuzzer tripped over a risc-v target issue in the expansion of CRCs. In particular we want to use brev instruction to improve the reflection code. In the case where the item to be reflected is smaller than a word we would end up triggering an ICE due to mode mismatching since the expansion code asks for the operation in word_mode. I was briefly confused by the multiple calls into this code, but we have to reflect multiple values and those calls may be reflecting different sized items. So seeing one in SI, then another in QI is sensible. The fix is pretty simple. In theory the item being reflected should always be word_size or smaller. So an assertion is added to verify that. If the item's size is smaller than a word, we can use a paradoxical subreg. The logical right shift after the brev should zero out any extraneous bits. It's unclear why we're passing a pointer to an RTX in this code. I left that as-is, but we can simplify the code a little bit by doing the dereference early and using the dereferenced value. PR middle-end/118084 gcc/ * config/riscv/riscv.cc (generate_reflecting_code_using_brev): Handle sub-word sized objects correctly. gcc/testsuite/ * gcc.target/riscv/pr118084.c: New test.
Diffstat (limited to 'gcc/testsuite/gcc.target/riscv')
-rw-r--r--gcc/testsuite/gcc.target/riscv/pr118084.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/riscv/pr118084.c b/gcc/testsuite/gcc.target/riscv/pr118084.c
new file mode 100644
index 0000000..2ffa1d7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr118084.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=rv32izk -mabi=ilp32 -Os" } */
+unsigned a;
+int main() {
+ int b = 8;
+ for (; b; b--)
+ if (a & 1)
+ a = a >> 1 ^ 30196000;
+ else
+ a >>= 1;
+}
+
+