[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
Mon Jul 9 10:52:52 PDT 2012
I am working on this.
Just wondering whether we should implement the decoding part (analysis) in .td file.
For example, add a 5-bit condition code for X86 instructions:
// To avoid decode the condition code from op code.
bits<5> CondCode = 31;
let CondCode = 13 in
defm CMOVO : CMOV<0x40, "cmovo" , X86_COND_O>;
We can add isCMov as well to differentiate CMOV from SET.
We will still implement the "synthesis" part in X86InstrInfo.cpp.
Let me know,
Thanks,
Manman
On Jul 6, 2012, at 2:24 PM, Manman Ren wrote:
>
> 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
>>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list