https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115921
--- Comment #3 from Jeffrey A. Law <law at gcc dot gnu.org> --- IIRC, the reason for that condition to to avoid spoiling certain cases where we want to ultimately generate shNadd instructions. It's a tradeoff. The shadd case is probably more important than avoiding the constant load from a performance standpoint, but we also don't know in advance if the shadd case will trigger. There are a couple of improvements we can make though. First, the shadd case is only important when ZBA is enabled. So if ZBA is not enabled, then we should go ahead and do the reassociation. Second if the shift count is not 1, 2 or 3, then ZBA doesn't apply and we can do the reassociation. I'll take care of adjusting the pattern for those cases.