[llvm-commits] [llvm] r159838 - in /llvm/trunk: lib/Target/X86/X86InstrArithmetic.td lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.h test/CodeGen/X86/jump_sign.ll

Jakob Stoklund Olesen stoklund at 2pi.dk
Fri Jul 6 14:14:32 PDT 2012


On Jul 6, 2012, at 10:36 AM, Manman Ren <mren at apple.com> wrote:

> Author: mren
> Date: Fri Jul  6 12:36:20 2012
> New Revision: 159838
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=159838&view=rev
> Log:
> X86: peephole optimization to remove cmp instruction
> 
> For each Cmp, we check whether there is an earlier Sub which make Cmp
> redundant. We handle the case where SUB operates on the same source operands as
> Cmp, including the case where the two source operands are swapped.
> 

Manman, I think these opcode tables are growing too big. We can do better by using analysis and synthesis functions.

Analysis: Given an opcode, compute (stem, cond-code, regbytes), where stem is (SET, JUMP, CMOVrr, CMOVrm), cond-code is one of the X86::CondCode enumerators, and regbytes is 2, 4, or 8 (only for CMOV).

Synthesis: Compute an opcode from (stem, cond-code, regwidth). Return 0 if no such opcode exists.

This would simplify your code a lot because you can go: Analyze - swap condcode - synthesize. The giant switch in commuteInstruction() would also go away.

We already have some of this functionality in place, see GetCondFromBranchOpc, GetCondBranchFromCond, and getCMovFromCond which I just added.

/jakob




More information about the llvm-commits mailing list