https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80770
--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jeff Law <[email protected]>: https://gcc.gnu.org/g:86964edc9964067c107a63efb957c50efa58b3a9 commit r17-77-g86964edc9964067c107a63efb957c50efa58b3a9 Author: Jeff Law <[email protected]> Date: Fri Apr 24 14:58:00 2026 -0600 [RISC-V][PR rtl-optimization/80770] Canonicalize extending byte loads for RISC-V In the process of debugging pr80770 with Shreya it became apparent that a failure to CSE certain memory references was inhibiting Shreya's RTL simplification from firing in all the cases we cared about as the simplifier requires two operands to be the same pseudo. The failure to CSE stems from having two QI loads which are sign extended to different sized destinations. As it turns out the code to fix that was something I already had in flight as it's a small piece of eliminating a few define_insn_and_split patterns (or simplifying them down to just a define_split). To expose the missed CSE what we really want to do is extend the value out to word mode in a temporary, then use a lowpart extraction to set the real destination. The key being we haven't changed the size of the load, just how widely it gets extended. Think of it as canonicalization for the purposes of CSE. This isn't the full set of changes I had in flight in that space, but does clean things up enough for QImode loads to get CSE'd better and is enough to trigger Shreya's pr80770 changes consistently for the testcodes we have on RISC-V. This has been spinning in my tester for a while. So it's clean on riscv64-elf, riscv32-elf as well as bootstrapped and regression tested on the Pioneer and BPI-F3. I'll wait for the pre-commit tester to do its thing before pushing to the trunk. In case it's not obvious, I'm focused on trickling RISC-V target improvements right now so as not to potentially interfere with the release process. So this doesn't include Shreya's simplify-rtx.cc changes. PR rtl-optimization/80770 gcc/ * config/riscv/riscv.md (zero_extendqi<SUPERQI:mode>2): Always extend out to a word and use a subreg lowpart extraction to get the right bits. (extend<SHORT:mode><SUPERQI:mode>2): Similarly. gcc/testsuite * gcc.target/riscv/rvv/base/vwaddsub-1.c: Adjust expected output.
