gnu/gcc/8effc5eed2bbadb40af6dde872bb24ef58a16a55 bpf: TARGET_RTX_COSTS: avoid multiply synthesis
The default cost of MULT/DIV/MOD in rtx_cost () is high: 5,7 insns
respectively. This causes even a trivial mpy by 7 to be synthesized.
Given these have direct equivalents in BPF ISA, fix the cost to generate
native BPF insns.
Note the existing divmod-licall-2.c test was a bit fragile as it forced
cast signed an actual unsigned int which is provably non-negative.
In the new cost model compiler would generate a native unsigned divide
even though it not available for -mcpu=v3, tripping up the test.
Fix by ensuring the arg is actually signed.
gcc/ChangeLog:
* config/bpf/bpf.cc (bpf_rtx_costs): Assign MPY/DIV/MOD cost 1.
gcc/testsuite/ChangeLog:
* gcc.target/bpf/divmod-libcall-2.c: Change args/ret to signed.
* gcc.target/bpf/mult-large.c: New test.
* gcc.target/bpf/mult-small.c: New test.
Signed-off-by: Vineet Gupta <vineet.gupta@linux.dev>
(cherry picked from commit c743ce6b75543fadea31ab8d518bba363bf5e44e)
4 files changed