This is the mail archive of the gcc-help@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]

Re: Tr : [redundency elimination, code motion, commun expression elimination] GCC optimizations


Jeff Law <law@redhat.com> writes:
> The tail merging code in the RTL optimizers might pick this stuff up
> and Tom's work on block merging might as well.  It'd be worth
> looking into why they aren't triggering.

Hmm, actually testing with a recent gcc snapshot, it _is_ merging the
two if-blocks:

   int a, b, c, d, e, f;
   extern void foo ();
   void t (int x)
   {
     if (x==1) { a=b; c=d; e=f; foo(); }
     if (x==2) { a=b; c=d; e=f; foo(); }
   }

=>

   t:
           cmpl	$1, %edi
           je	.L4
           cmpl	$2, %edi
           je	.L4
           rep
           ret
   .L4:
           movl	b(%rip), %eax
           movl	%eax, a(%rip)
           movl	d(%rip), %eax
           movl	%eax, c(%rip)
           movl	f(%rip), %eax
           movl	%eax, e(%rip)
           xorl	%eax, %eax
           jmp	foo
           ...
           .ident	"GCC: (Debian 20110924-1) 4.7.0 20110924 (experimental) [trunk revision 179143]"

-Miles

-- 
Quotation, n. The act of repeating erroneously the words of another. The words
erroneously repeated.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]