On 6/16/25 10:08 PM, Dongyan Chen wrote:
Hi, I've come across a question regarding the branch cost of gcc. In the link
https://gcc.godbolt.org/z/hnddevd5h, gcc fails to recognize the optimization
branch judgment, while llvm does. I eventually discovered that the value of the 
branch
cost was too small. Moreover, in that link, if I add "-mbranch-cost=4" (a larger
number can also be used) for gcc, the zicond extension functions properly. So, 
is
it necessary to modify the branch cost for gcc? According to the source code, 
the
default mtun is rocket, which has a branch cost of 3. I think it should be set 
to 4.

gcc/ChangeLog:

        * config/riscv/riscv.cc: Change the branch cost.

gcc/testsuite/ChangeLog:

        * 
gcc.target/riscv/zicond-primitiveSemantics_compare_reg_reg_return_reg_reg.c: 
New test.
Also note this failed many tests in the pre-commit CI system. That's not unusual for a change like this. Anyway link to the CI failures:

https://github.com/ewlu/gcc-precommit-ci/issues/3531#issuecomment-2978926449




You will need to evaluate the failures. If there are failures that really are code quality regressions you will need to start a discussion here about the details of the regression and how we would go about fixing he regression.

For failures that are just trivial differences causing the scan-asm tests to fail, you will need to update the tests.

Going forward you need to make sure you're doing basic testing before submitting patches.

jeff

Reply via email to