Skip to content
  • grischka's avatar
    jump optimizations · 8227db3a
    grischka authored
    This unifies VT_CMP with VT_JMP(i) by using mostly VT_CMP
    with both a positive and a negative jump target list.
    
    Such we can delay putting the non-inverted or inverted jump
    until we can see which one is nore suitable (in most cases).
    
    example:
        if (a && b || c && d)
            e = 0;
    
    before this patch:
       a:	8b 45 fc             	mov    0xfffffffc(%ebp),%eax
       d:	83 f8 00             	cmp    $0x0,%eax
      10:	0f 84 11 00 00 00    	je     27 <main+0x27>
      16:	8b 45 f8             	mov    0xfffffff8(%ebp),%eax
      19:	83 f8 00             	cmp    $0x0,%eax
      1c:	0f 84 05 00 00 00    	je     27 <main+0x27>
      22:	e9 22 00 00 00       	jmp    49 <main+0x49>
      27:	8b 45 f4             	mov    0xfffffff4(%ebp),%eax
      2a:	83 f8 00             	cmp    $0x0,%eax
      2d:	0f 84 11 00 00 00    	je     44 <main+0x44>
      33:	8b 45 f0             	mov    0xfffffff0(%ebp),%eax
      36:	83 f8 00             	cmp    $0x0,%eax
      39:	0f 84 05 00 00 00    	je     44 <main+0x44>
      3f:	e9 05 00 00 00       	jmp    49 <main+0x49>
      44:	e9 08 00 00 00       	jmp    51 <main+0x51>
      49:	b8 00 00 00 00       	mov    $0x0,%eax
      4e:	89 45 ec             	mov    %eax,0xffffffec(%ebp)
      51:   ...
    
    with this patch:
       a:	8b 45 fc             	mov    0xfffffffc(%ebp),%eax
       d:	83 f8 00             	cmp    $0x0,%eax
      10:	0f 84 0c 00 00 00    	je     22 <main+0x22>
      16:	8b 45 f8             	mov    0xfffffff8(%ebp),%eax
      19:	83 f8 00             	cmp    $0x0,%eax
      1c:	0f 85 18 00 00 00    	jne    3a <main+0x3a>
      22:	8b 45 f4             	mov    0xfffffff4(%ebp),%eax
      25:	83 f8 00             	cmp    $0x0,%eax
      28:	0f 84 14 00 00 00    	je     42 <main+0x42>
      2e:	8b 45 f0             	mov    0xfffffff0(%ebp),%eax
      31:	83 f8 00             	cmp    $0x0,%eax
      34:	0f 84 08 00 00 00    	je     42 <main+0x42>
      3a:	b8 00 00 00 00       	mov    $0x0,%eax
      3f:	89 45 ec             	mov    %eax,0xffffffec(%ebp)
      42:   ...
    8227db3a