Message ID | CAFULd4Z+BZ3-rLckm0s5cQtjnrJ8evAneccZbNvwS78ynLO5vA@mail.gmail.com |
---|---|
State | New |
Headers | show |
On Sun, Feb 5, 2012 at 4:27 PM, Uros Bizjak <ubizjak@gmail.com> wrote: > 2012-02-05 Uros Bizjak <ubizjak@gmail.com> > > PR target/28685 > * config/i386/i386.c (TARGET_FLAGS_REGNUM): New. > Hmm, how is this (apparently new in 2011) TARGET_FLAGS_REGNUM different from the older targetm.fixed_condition_code_regs? Ciao! Steven
On Sun, Feb 5, 2012 at 6:27 PM, Steven Bosscher <stevenb.gcc@gmail.com> wrote: >> PR target/28685 >> * config/i386/i386.c (TARGET_FLAGS_REGNUM): New. >> > > Hmm, how is this (apparently new in 2011) TARGET_FLAGS_REGNUM > different from the older targetm.fixed_condition_code_regs? This is how backend enables the pass, please see gate_compare_elim_after_reload function in gcc/compare-elim.c. FWIW, the value could be anything != INVALID_REGNUM. Uros.
On 02/05/2012 07:27 AM, Uros Bizjak wrote: > Hello! > > Attached patch enables post-reload compare optimization pass for x86 targets. Hmm. Well, the only thing that's going to work for x86 is the double-compare elimination portion. If we want to use this pass for x86, then for 4.8 we should also fix the discrepancy between the compare-elim canonical [(operate) (set-cc)] and the combine canonical [(set-cc) (operate)] (Because of the simplicity of the substitution in compare-elim, I prefer the former as the canonical canonical.) And, really, we ought to come up with some trick to eliminate some of the redundancy in patterns in the md file too. r~
On Mon, Feb 6, 2012 at 9:59 PM, Richard Henderson <rth@redhat.com> wrote: > On 02/05/2012 07:27 AM, Uros Bizjak wrote: >> Hello! >> >> Attached patch enables post-reload compare optimization pass for x86 targets. > > Hmm. Well, the only thing that's going to work for x86 is the double-compare > elimination portion. > > If we want to use this pass for x86, then for 4.8 we should also fix the > discrepancy between the compare-elim canonical > > [(operate) > (set-cc)] > > and the combine canonical > > [(set-cc) > (operate)] > > (Because of the simplicity of the substitution in compare-elim, I prefer > the former as the canonical canonical.) You are probably referring to following testcase: --cut here-- int test (int a, int b) { int lt = a + b < 0; int eq = a + b == 0; if (lt) return 1; return eq; } --cut here-- where combine creates: Trying 8 -> 9: Successfully matched this instruction: (parallel [ (set (reg:CCZ 17 flags) (compare:CCZ (plus:SI (reg/v:SI 63 [ a ]) (reg/v:SI 64 [ b ])) (const_int 0 [0]))) (set (reg:SI 60 [ D.1710 ]) (plus:SI (reg/v:SI 63 [ a ]) (reg/v:SI 64 [ b ]))) ]) Uros.
On Feb 6, 2012, at 12:59 PM, Richard Henderson wrote: > And, really, we ought to come up with some trick to eliminate some of the > redundancy in patterns in the md file too. :-) That'd be awesome...
Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 183904) +++ config/i386/i386.c (working copy) @@ -38685,6 +38685,9 @@ #undef TARGET_EXPAND_TO_RTL_HOOK #define TARGET_EXPAND_TO_RTL_HOOK ix86_maybe_switch_abi +#undef TARGET_FLAGS_REGNUM +#define TARGET_FLAGS_REGNUM FLAGS_REG + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P ix86_legitimate_address_p Index: testsuite/gcc.target/i386/pr28685.c =================================================================== --- testsuite/gcc.target/i386/pr28685.c (revision 0) +++ testsuite/gcc.target/i386/pr28685.c (revision 0) @@ -0,0 +1,12 @@ +/* { dg-options "-O2" } */ + +int test(int a, int b) +{ + int lt = a < b; + int eq = a == b; + if (lt) + return 1; + return eq; +} + +/* { dg-final { scan-assembler-times "cmp" 1 } } */