[llvm-commits] [llvm] r48356 - /llvm/trunk/lib/Target/X86/README.txt

Christopher Lamb christopher.lamb at gmail.com
Sat Mar 15 14:01:22 PDT 2008


Here's a proposed solution. It seems to work OK for me. It'll be even  
better when the undef and insert_subreg coalescing support gets done.
--
Chris


On Mar 14, 2008, at 10:34 AM, Chris Lattner wrote:

> On Mar 14, 2008, at 10:15 AM, Evan Cheng wrote:
>> This seems like a target independent dag combiner xform?
>
> Turning the first into the second is target independent, and should
> actually be done in instcombine.  The problem is that the second one
> generates worse code from the x86 backend than the first one.
>
> On PPC and ARM, they generate equally good code (on ARM they both
> compile to identical instructions even) so consider this to be "X86
> generates inefficient code for:
>
> define i32 @test2(i32 %f12) {
> 	%f11 = shl i32 %f12, 8
> 	%tmp7.25 = ashr i32 %f11, 24
> 	ret i32 %tmp7.25
> }"
>
> :)
>
> -Chris
>
>
>> On Mar 13, 2008, at 11:00 PM, Chris Lattner wrote:
>>
>>>
>>>
>>> +These two functions perform identical operations:
>>> +
>>> +define i32 @test(i32 %f12) {
>>> +	%tmp7.25 = lshr i32 %f12, 16		
>>> +	%tmp7.26 = trunc i32 %tmp7.25 to i8
>>> +	%tmp78.2 = sext i8 %tmp7.26 to i32
>>> +	ret i32 %tmp78.2
>>> +}
>>> +
>>> +define i32 @test2(i32 %f12) {
>>> +	%f11 = shl i32 %f12, 8
>>> +	%tmp7.25 = ashr i32 %f11, 24
>>> +	ret i32 %tmp7.25
>>> +}
>>> +
>>> +but the first compiles into significantly better code on x86-32:
>>> +
>>> +_test:
>>> +	movsbl	6(%esp), %eax
>>> +	ret
>>> +_test2:
>>> +	movl	4(%esp), %eax
>>> +	shll	$8, %eax
>>> +	sarl	$24, %eax
>>> +	ret
>>> +
>>> +and on x86-64:
>>> +
>>> +_test:
>>> +	shrl	$16, %edi
>>> +	movsbl	%dil, %eax
>>> +	ret
>>> +_test2:
>>> +	shll	$8, %edi
>>> +	movl	%edi, %eax
>>> +	sarl	$24, %eax
>>> +	ret
>>> +
>>> +I would like instcombine to canonicalize the first into the second
>>> (since it is
>>> +shorter and doesn't involve type width changes) but the x86 backend
>>> needs to do
>>> +the right thing with the later sequence first.
>>> +
>>> +//
>>> =
>>> =
>>> =
>>> -------------------------------------------------------------------- 
>>> -
>>> ===//
>>>
>>>
>>> _______________________________________________
>>> 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

--
Christopher Lamb



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20080315/274935ed/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x86-codegen-tweak.patch
Type: application/octet-stream
Size: 3612 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20080315/274935ed/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20080315/274935ed/attachment-0001.html>


More information about the llvm-commits mailing list