This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hello! Attached patch implements post-reload compare elimination pass for x86 target. The patch converts arithmetic and logic patterns (that is: plus, minus, and, or, xor, neg, one complement) to the patterns, recognized by post-reload cmp elimination pass, together with all relevant splitters and peephole2 RTXes to "conforming" patterns. The patch bootstraps OK and regression test shows no regressions, so the patch can be considered as production quality patch. The purpose of the patch however, is to look at potential issues with post-reload cmp elimination pass. First, some numbers: 1. compiling combine.i: without the patch: 2225 cmp, 1279 test instructions with the patch: 2228 cmp, 1278 test instructions 2. compiling insn-attrtab.i: without the patch: 17763 cmp, 11988 test instructions with the patch: 17756 cmp, 12023 test instructions So, post-reload comparison elimination pass leaves some ~40 test instructions when compiling insn-attrtab.i. Looking at the differences, there are two problems: 1. post-reload splitters converts add (and some other) patterns to LEA RTXes, where clobber is not present: RA is free to allocate registers to PLUS RTX to form a non-destructive add (this RTX results in LEA insn). Unfortunately, LEA has no "interesting" FLAGS_REG clobber, so following compare can't be merged with preceding arith instruction. This problem is not present in pre-reload compare elimination pass, and results in quite some non-merged compares. 2. post-reload splitter converts non-SI mode patterns to SImode to avoid size prefixes: ;; Avoid redundant prefixes by splitting HImode arithmetic to SImode. Post-reload compare elimination pass is not able to undo this change, and it results in: orl %eax, %r12d # 10751 *iorsi_1/1 [length = 3] testb %r12b, %r12b # 5774 *cmpqi_ccno_1/1 [length = 3] Although the second problem can be "fixed" by restricting the splitter with "epilogue_completed", I don't think the problem with LEAs can be fixed by restricting the relevant splitters to split4 pass. All in all, my opinion is, that post-reload compare-elimination pass is not that effective for x86, and brings more trouble than gain. Maybe we can complement pre-reload pass with post-reload, but this would involve many new patterns (insn, splitter and peephole2 patterns) for a very small (if any) gain. Any other opinions? 2012-04-25 Uros Bizjak <ubizjak@gmail.com> * config/i386/i386.c (TARGET_FLAGS_REGNUM): Define. (ix86_match_ccmode): Find first SET of flags reg from COMPARE RTX. * config/i386/i386.md (*add<mode>_2): Put compare RTX after operator RTX, as expected by post-reload compare elimination pass. (*addsi_2_zext): Ditto. (*add<mode>_5): Remove. (*sub<mode>_2): Put compare RTX after operator RTX. (*subsi_2_zext): Ditto. (*anddi_2): Ditto. (*andqi_2_maybe_si): Ditto. (*and<mode>_2): Ditto. (*andsi_2_zext): Ditto. (*<code><mode>_2): Ditto. (*<code>si_2_zext): Ditto. (*neg<dwi>2_doubleword): Update RTX. (*neg<mode>2_cmpz): Put compare RTX after operator RTX. (*negsi2_cmpz_zext): Ditto. (*one_cmpl<mode>2_2): Ditto. Update corresponding splitter. (*one_cmplsi2_2_zext): Ditto. Update corresponfing splitter. * config/i386/i386.md: Update peephole2 patterns for changed RTXes. The patch was tested on x86_64-pc-linux-gnu {,-m32} and is NOT intended to be committed to SVN. Uros.
Attachment:
p.diff.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |