On Tue, May 09, 2017 at 06:06:47PM +0200, Uros Bizjak wrote: > Attached patch enables post-reload compare elimination pass by > providing expected patterns (duplicates of existing patterns with > setters of reg and flags switched in the parallel) for flag setting > arithmetic instructions. > > The merge triggers more than 3000 times during the gcc bootstrap, > mostly in cases where intervening memory load or store prevents > combine from merging the arithmetic insn and the following compare. > > Also, some recent linux x86_64 defconfig build results in ~200 merges, > removing ~200 test/cmp insns. Not much, but I think the results still > warrant the pass to be enabled.
Isn't the right fix instead to change the compare-elim.c pass to either accept both reg vs. flags orderings in parallel, or both depending on some target hook, or change it to the order i386.md and most other major targets use and just fix up mn10300/rx (and aarch64?) to use the same order? I think this has been discussed before already several times. > > 2017-05-09 Uros Bizjak <ubiz...@gmail.com> > > * config/i386/i386-protos.h (ix86_match_ccmode_last): New prototype. > * config/i386/i386.c (ix86_match_ccmode_1): Rename from > ix86_match_ccmode. Add "last" argument. Make function static inline. > (ix86_match_ccmode): New function. > (ix86_match_ccmode_last): Ditto. > (TARGET_FLAGS_REGNUM): Define. > * config/i386/i386.md (*add<mode>_2b): New insn pattern. > (*sub<mode>_2b): Ditto. > (*and<mode>_2b): Ditto. > (*<any_or:code><mode>_2b): Ditto. Jakub