[LLVMdev] Testing LLVM on OS X

Patrick Flanagan valtrain at mac.com
Mon May 17 23:43:01 PDT 2004

> Okay, I changed the C backend to emit syntactic loops around the real
> loops, and it seems to make a big difference.  LLVM now generates this
> code (note that the actual loop is not actually responsible for control
> flow, it's unreachable):
> ... which is exactly what we want.  Patrick, I would appreciate it if 
> you
> could rerun your tests on PPC and let me know if this helps.  :)

Aside from this syntactic loop stuff, I was looking over gzip some more 
and found another area that could be improved.

In gzip's longest_match function, part of the code generated by CBE 
looks like this:

   l8_chain_length_2E_039 = (((l2_tmp_2E_182) ? (4294967295u) : (0u))) + 

.. some other code ...

    ... some other code ...
   l2_tmp_2E_182 = l8_tmp_2E_180 > l8_mem_tmp_2E_0;

  if (l2_tmp_2E_182) {
     goto l13_shortcirc_next_2E_11;
   } else {
     goto l13_UnifiedReturnBlock;

Basically it does that check and puts the result in  l2_tmp_2E_182, 
then uses that in the if check and the ternary thing. When this is 
compiled, the assembly that it generates for that check/assignment is:

subc r29, r25, r2
subfe r29,r29,r29
neg r29,r29

This is pretty slow compared to just doing the check on the fly (and 
being able to just use a compare instruction). If I manually edit the 
code to change it to:

   l8_chain_length_2E_039 = ((l8_tmp_2E_180 > l8_mem_tmp_2E_0) ? 
(4294967295u) : (0u))) + l8_chain_length_2E_1;

.. some other code ...


  if (l8_tmp_2E_180 > l8_mem_tmp_2E_0) {
     goto l13_shortcirc_next_2E_11;
   } else {
     goto l13_UnifiedReturnBlock;

then the assembly generated becomes a cmplw and branch where it occurs.

Making this change in only this one spot causes the time to run to 
decrease 69 seconds, giving it a speedup of 6% from the 5/12 LLVM CVS. 
I noticed several spots in the CBE code where this type of code was 
generated, and if it was changed to emit code the 2nd way it would 
presumably help even more.

Lastly, did you ever hear anything back from that group that was 
working on the PPC JIT compiler? :)



More information about the llvm-dev mailing list