[PR rtl-optimization/107455] Eliminate unnecessary constant load
This resurrects a patch from a bit over 2 years ago that I never wrapped up. IIRC, I ended up up catching covid, then in the hospital for an unrelated issue and it just got dropped on the floor in the insanity. The basic idea here is to help postreload-cse eliminate more const/copies by recording a small set of conditional equivalences (as Richi said in 2022, "Ick"). It was originally to help eliminate an unnecessary constant load I saw in coremark, but as seen in BZ107455 the same issues show up in real code as well. Bootstrapped and regression tested on x86-64, also been through multiple spins in my tester. Changes since v2: - Simplified logic for blocks to examine - Remove redundant tests when filtering blocks to examine - Remove bogus check which only allowed reg->reg copies Changes since v1: Richard B and Richard S both had good comments last time around and their requests are reflected in this update: - Use rtx_equal_p rather than pointer equality - Restrict to register "destinations" - Restrict to integer modes - Adjust entry block handling My own wider scale testing resulted in a few more changes. - Robustify extracting the (set (pc) ... ), which then required ... - Handle if src/dst are clobbered by the conditional branch - Fix logic error causing too many equivalences to be recorded PR rtl-optimization/107455 gcc/ * postreload.cc (reload_cse_regs_1): Take advantage of conditional equivalences. gcc/testsuite * gcc.target/riscv/pr107455-1.c: New test. * gcc.target/riscv/pr107455-2.c: New test.
Loading
Please register or sign in to comment