[llvm-commits] [Please Review] [PATCH] optimization of -(x != 0) to use neg in X86
Evan Cheng
evan.cheng at apple.com
Sun May 6 11:20:25 PDT 2012
The first chunk seems right to me.
+// sub 0, reg
+def : Pat<(X86sub_flag 0, GR8 :$src), (NEG8r GR8 :$src)>;
+def : Pat<(X86sub_flag 0, GR16:$src), (NEG16r GR16:$src)>;
+def : Pat<(X86sub_flag 0, GR32:$src), (NEG32r GR32:$src)>;
+def : Pat<(X86sub_flag 0, GR64:$src), (NEG64r GR64:$src)>;
+
I'm very skeptical this would ever match. I think we handle it with c++ code in isel. Or am I confusing the issue? See rdar://6172640 and rdar://11069732.
+// sub 0, mem
+def : Pat<(store (X86sub_flag 0, (loadi8 addr:$dst)), addr:$dst),
+ (NEG8m addr:$dst)>;
+def : Pat<(store (X86sub_flag 0, (loadi16 addr:$dst)), addr:$dst),
+ (NEG16m addr:$dst)>;
+def : Pat<(store (X86sub_flag 0, (loadi32 addr:$dst)), addr:$dst),
+ (NEG32m addr:$dst)>;
+def : Pat<(store (X86sub_flag 0, (loadi64 addr:$dst)), addr:$dst),
+ (NEG64m addr:$dst)>;
Evan
On May 6, 2012, at 8:20 AM, Manman Ren wrote:
>
> Hi Duncan,
>
> I created a ISD::SUB node with two outputs and used the 2nd output for X86ISD::SETCC_CARRY.
>
> ISD::SUB is not supposed to have two outputs.
> Now I used X86ISD::SUB with two outputs and added patterns to match X86ISD::SUB(0, r).
>
> Thanks,
> Manman
>
> On May 5, 2012, at 4:15 AM, Duncan Sands wrote:
>
>> Hi Manman,
>>
>>> PING
>>
>> why was it failing before, i.e. what did you fix?
>>
>> Ciao, Duncan.
>>
>>>
>>> On May 3, 2012, at 7:14 PM, manman ren wrote:
>>>
>>>>
>>>> X86: optimization for -(x != 0)
>>>>
>>>> This patch will optimize -(x != 0) on X86
>>>> FROM
>>>> cmpl $0x01,%edi
>>>> sbbl %eax,%eax
>>>> notl %eax
>>>> TO
>>>> negl %edi
>>>> sbbl %eax %eax
>>>>
>>>> In order to generate negl, I added patterns in Target/X86/X86InstrCompiler.td:
>>>> def : Pat<(X86sub_flag 0, GR32:$src), (NEG32r GR32:$src)>;
>>>>
>>>> This is my first experience with tablegen, please review.
>>>> The initial version of this patch (r155853) was the root cause of PR12720 and I did verify this patch against PR12720.
>>>>
>>>> Thanks,
>>>> Manman
>>>>
>>>> <sext_ne.patch>
>>>>
>>>>
>>>>
>>>> On Apr 30, 2012, at 11:38 AM, manman ren wrote:
>>>>
>>>>>>
>>>>>>
>>>>>> On Apr 27, 2012, at 6:03 PM, manman ren wrote:
>>>>>>
>>>>>>>
>>>>>>> This patch will optimize -(x != 0) on X86
>>>>>>> FROM
>>>>>>> cmpl $0x01,%edi
>>>>>>> sbbl %eax,%eax
>>>>>>> notl %eax
>>>>>>> TO
>>>>>>> negl %edi
>>>>>>> sbbl %eax %eax
>>>>>>>
>>>>>>> Please review& provide feedback,
>>>>>>> Thanks,
>>>>>>> Manman
>>>>>>>
>>>>>>> <sext_ne.patch>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> llvm-commits mailing list
>>>>>>> llvm-commits at cs.uiuc.edu
>>>>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>>>>
>>>>>
>>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
> _______________________________________________
> 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