Skip to content
Snippets Groups Projects
Commit cbea72b2 authored by Raphael Moreira Zinsly's avatar Raphael Moreira Zinsly Committed by Jeff Law
Browse files

[PATCH 1/3] RISC-V: Improve codegen for negative repeating large constants

Improve handling of constants where its upper and lower 32-bit
halves are the same and have negative values.

e.g. for:

unsigned long f (void) { return 0xf0f0f0f0f0f0f0f0UL; }

Without the patch:

li      a0,-252645376
addi    a0,a0,240
li      a5,-252645376
addi    a5,a5,241
slli    a5,a5,32
add     a0,a5,a0

With the patch:

li      a5,252645376
addi    a5,a5,-241
slli    a0,a5,32
add     a0,a0,a5
xori    a0,a0,-1

gcc/ChangeLog:
	* config/riscv/riscv.cc (riscv_split_integer_cost): Adjust the
	cost of negative repeating constants.
	(riscv_split_integer): Handle negative repeating constants.

gcc/testsuite/ChangeLog:
	* gcc.target/riscv/synthesis-11.c: New test.
parent 5326306e
No related branches found
No related tags found
Loading
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