Skip to content
Snippets Groups Projects
Commit c8957c87 authored by Jovan Vukic's avatar Jovan Vukic Committed by Jeff Law
Browse files

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.
parent df3bda45
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment