-
- Downloads
RISC-V: Optimize branches with shifted immediate operands
After the valuable feedback I received, it’s clear to me that the oversight was in the tests showing the benefits of the patch. In the test file, I added functions f5 and f6, which now generate more efficient code with fewer instructions. Before the patch: f5: li a4,2097152 addi a4,a4,-2048 li a5,1167360 and a0,a0,a4 addi a5,a5,-2048 beq a0,a5,.L4 f6: li a5,3407872 addi a5,a5,-2048 and a0,a0,a5 li a5,1114112 beq a0,a5,.L7 After the patch: f5: srli a5,a0,11 andi a5,a5,1023 li a4,569 beq a5,a4,.L5 f6: srli a5,a0,11 andi a5,a5,1663 li a4,544 beq a5,a4,.L9 PR target/115921 gcc/ChangeLog: * config/riscv/iterators.md (any_eq): New code iterator. * config/riscv/riscv.h (COMMON_TRAILING_ZEROS): New macro. (SMALL_AFTER_COMMON_TRAILING_SHIFT): Ditto. * config/riscv/riscv.md (*branch<ANYI:mode>_shiftedarith_<optab>_shifted): New pattern. gcc/testsuite/ChangeLog: * gcc.target/riscv/branch-1.c: Additional tests.
Showing
- gcc/config/riscv/iterators.md 4 additions, 0 deletionsgcc/config/riscv/iterators.md
- gcc/config/riscv/riscv.h 12 additions, 0 deletionsgcc/config/riscv/riscv.h
- gcc/config/riscv/riscv.md 32 additions, 0 deletionsgcc/config/riscv/riscv.md
- gcc/testsuite/gcc.target/riscv/branch-1.c 15 additions, 3 deletionsgcc/testsuite/gcc.target/riscv/branch-1.c
Loading
Please register or sign in to comment