https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108031
Jeffrey A. Law <law at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |120763
--- Comment #2 from Jeffrey A. Law <law at gcc dot gnu.org> ---
So this won't resolve the problem, but the first thing that jumped out was the
fact that we're being overly loose in the operand predicates for some of the
atomics. In particular prior to reloading we're allowing any generic memory
operand when in fact the amo operations such as amoadd only allow register
indirect.
As a result CSE never really gets a shot at optimizing the addresses. If we
hack around that the relevant insns are exposed to CSE. I can then confirm
that CSE will find the related value from the earlier lui/addi pair. Costing
then gets in the way. If I hack around the costing issue I get:
lui a5,%hi(s)
addi a5,a5,%lo(s)
li a4,1
amoadd.w a0,a4,0(a5)
addi a5,a5,4
amoadd.w a3,a4,0(a5)
addw a0,a0,a3
ret
The great irony here is atomics and costing are precisely the space where
Shreya has been working lately. So this may be a good follow-up to her current
efforts. I'll update here after I sync with Shreya.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120763
[Bug 120763] [meta-bug] Tracker for bugs to visit during weekly RISC-V meeting