[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

Manman Ren mren at apple.com
Fri Jul 6 14:24:55 PDT 2012


I thought about that as well when looking at your change r159695.
I was a little worried about the performance, since I need to go through the switch twice, once to analyze the condition code, the other time to synthesize the opcode.
But the interface will be general enough so we can all use it.
Will work on it.

Thanks,
Manman

On Jul 6, 2012, at 2:14 PM, Jakob Stoklund Olesen wrote:

> 
> 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