[llvm-commits] [llvm] r44981 - in /llvm/trunk: lib/Transforms/Scalar/CodeGenPrepare.cpp test/CodeGen/X86/opt-ext-uses.ll

Evan Cheng evan.cheng at apple.com
Wed Dec 12 23:48:19 PST 2007


On Dec 12, 2007, at 8:40 PM, Chris Lattner wrote:

> On Dec 12, 2007, at 7:32 PM, Evan Cheng wrote:
>
>> Author: evancheng
>> Date: Wed Dec 12 21:32:53 2007
>> New Revision: 44981
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=44981&view=rev
>> Log:
>> Be extra careful with extension use optimation. Now turned on by
>> default.
>
> FYI, on your testcase with -print-isel-input, it looks like multiple
> instructions are sunk:
>
>
> cond_true188:		; preds = %entry
> 	trunc i32 %tmp180181 to i16		; <i16>:0 [#uses=1]
> 	trunc i32 %tmp180181 to i16		; <i16>:1 [#uses=1]
> 	%tmp195196 = trunc i16 %0 to i8		; <i8> [#uses=0]
> 	ret i16 %1
>
> Is this desired?

No it's not. I'll look.

Evan

>
> -Chris
>
>>
>>
>> Modified:
>>    llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
>>    llvm/trunk/test/CodeGen/X86/opt-ext-uses.ll
>>
>> Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ 
>> Scalar/CodeGenPrepare.cpp?rev=44981&r1=44980&r2=44981&view=diff
>>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> ===================================================================== 
>> =
>> --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
>> +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Wed Dec 12
>> 21:32:53 2007
>> @@ -36,7 +36,7 @@
>>
>> namespace {
>>   cl::opt<bool> OptExtUses("optimize-ext-uses",
>> -                           cl::init(false), cl::Hidden);
>> +                           cl::init(true), cl::Hidden);
>> }
>>
>> namespace {
>> @@ -929,6 +929,10 @@
>>   if (Src->hasOneUse())
>>     return false;
>>
>> +  // Only do this xform is truncating is free.
>> +  if (!TLI->isTruncateFree(I->getType(), Src->getType()))
>> +    return false;
>> +
>>   // Only safe to perform the optimization if the source is also
>> defined in
>>   // this block.
>>   if (!isa<Instruction>(Src) || DefBB != cast<Instruction>(Src)-
>>> getParent())
>> @@ -952,8 +956,11 @@
>>   for (Value::use_iterator UI = Src->use_begin(), E = Src->use_end();
>>        UI != E; ++UI) {
>>     Instruction *User = cast<Instruction>(*UI);
>> -    if (User->getParent() == DefBB) continue;
>> -    if (isa<PHINode>(User))
>> +    BasicBlock *UserBB = User->getParent();
>> +    if (UserBB == DefBB) continue;
>> +    // Be conservative. We don't want this xform to end up
>> introducing
>> +    // reloads just before load / store instructions.
>> +    if (isa<PHINode>(User) || isa<LoadInst>(User) ||
>> isa<StoreInst>(User))
>>       return false;
>>   }
>>
>>
>> Modified: llvm/trunk/test/CodeGen/X86/opt-ext-uses.ll
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ 
>> X86/opt-ext-uses.ll?rev=44981&r1=44980&r2=44981&view=diff
>>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> ===================================================================== 
>> =
>> --- llvm/trunk/test/CodeGen/X86/opt-ext-uses.ll (original)
>> +++ llvm/trunk/test/CodeGen/X86/opt-ext-uses.ll Wed Dec 12 21:32:53
>> 2007
>> @@ -1,4 +1,4 @@
>> -; RUN: llvm-as < %s | llc -march=x86 -optimize-ext-uses=true | grep
>> movw | count 1
>> +; RUN: llvm-as < %s | llc -march=x86 | grep movw | count 1
>>
>> define i16 @t() signext  {
>> entry:
>>
>>
>> _______________________________________________
>> 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