When I use the -mbranch-cost
parameter for -mtune=sifive-7-series
, I don’t see the difference in generated assembly code no matter the value I use. However, if I use it with -mtune=rocket
, I get either branched instructions or czero
instructions, depending on the value.
Below is the test example and the assembly output for GCC 14.1.0 for RISC-v and the given -mtune
value. Feel free to change -mtune
and -mbranch-cost
to test the issue I’ve described above.
https://godbolt.org/z/3dGvn3oq4
I’m wondering how does GCC process -mbranch-cost
value we provide and why does it not make a difference for sifive-7-series
and is that for some reason expected behavior.
I tried looking into sifive-7.md
and riscv.cc
files but I’m a bit new to the GCC internals so it is hard for me to identify the problem or even why doesn’t the code process -mbranch-cost
in the same way for sifive
and rocket
.
lotobis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.