------- Comment #49 from vvv at ru dot ru  2009-05-20 21:38 -------
(In reply to comment #48)
How this patches work? Is it required some special options?

# /media/disk-1/B/bin/gcc --version
gcc (GCC) 4.5.0 20090520 (experimental)
# cat test.c
void f(int i)
{
        if (i == 1) F(1);
        if (i == 2) F(2);
        if (i == 3) F(3);
        if (i == 4) F(4);
        if (i == 5) F(5);
}
extern int F(int m);
void func(int x)
{
        int u = F(x);
        while (u)
                u = F(u)*3+1;
}
# /media/disk-1/B/bin/gcc -o t test.c -O2 -c -mtune=k8
# objdump -d t
0000000000000000 <f>:
   0:   83 ff 01                cmp    $0x1,%edi
   3:   74 1b                   je     20 <f+0x20>
   5:   83 ff 02                cmp    $0x2,%edi
   8:   74 16                   je     20 <f+0x20>
   a:   83 ff 03                cmp    $0x3,%edi
   d:   74 11                   je     20 <f+0x20>
   f:   83 ff 04                cmp    $0x4,%edi
  12:   74 0c                   je     20 <f+0x20>
  14:   83 ff 05                cmp    $0x5,%edi
  17:   74 07                   je     20 <f+0x20>
  19:   f3 c3                   repz retq 
  1b:   0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)
  20:   31 c0                   xor    %eax,%eax
  22:   e9 00 00 00 00          jmpq   27 <f+0x27>
  27:   66 0f 1f 84 00 00 00    nopw   0x0(%rax,%rax,1)
  2e:   00 00 

0000000000000030 <func>:
  30:   48 83 ec 08             sub    $0x8,%rsp
  34:   e8 00 00 00 00          callq  39 <func+0x9>
  39:   85 c0                   test   %eax,%eax
  3b:   89 c7                   mov    %eax,%edi
  3d:   74 0e                   je     4d <func+0x1d>
  3f:   90                      nop    
  40:   e8 00 00 00 00          callq  45 <func+0x15>
  45:   8d 7c 40 01             lea    0x1(%rax,%rax,2),%edi
  49:   85 ff                   test   %edi,%edi
  4b:   75 f3                   jne    40 <func+0x10>
  4d:   48 83 c4 08             add    $0x8,%rsp
  51:   c3                      retq   

I can't see any padding in function f :(

PS. In file config/i386/i386.c (ix86_avoid_jump_mispredicts)

  /* Look for all minimal intervals of instructions containing 4 jumps.
...

Not jumps, but _branches_ (CALL, JMP, conditional branches, or returns) 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39942

Reply via email to