[llvm-commits] [llvm] r171279 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp test/Transforms/InstCombine/store.ll

Chris Lattner sabre at nondot.org
Sat Jan 5 08:44:41 PST 2013


Done in r171627, thanks!

-Chris

On Dec 31, 2012, at 4:52 AM, Nuno Lopes <nunoplopes at sapo.pt> wrote:

> BTW, there is already a function to merge TBAA data from two instructions (MDNode::getMostGenericTBAA):
> http://llvm.org/docs/doxygen/html/classllvm_1_1MDNode.html#a3c210e8905029a012df3384a7eeb63ad
> 
> Nuno
> 
> ----- Original Message -----
>> Author: lattner
>> Date: Mon Dec 31 02:10:58 2012
>> New Revision: 171279
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=171279&view=rev
>> Log:
>> teach instcombine to preserve TBAA tag when merging two stores, part of
>> PR14753
>> 
>> Modified:
>>   llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
>>   llvm/trunk/test/Transforms/InstCombine/store.ll
>> 
>> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp?rev=171279&r1=171278&r2=171279&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp (original)
>> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp Mon Dec 31 02:10:58 2012
>> @@ -802,6 +802,13 @@
>>  InsertNewInstBefore(NewSI, *BBI);
>>  NewSI->setDebugLoc(OtherStore->getDebugLoc());
>> 
>> +  // If the two stores had the same TBAA tag, preserve it.
>> +  if (MDNode *TBAATag1 = SI.getMetadata(LLVMContext::MD_tbaa))
>> +    if (MDNode *TBAATag2 = OtherStore->getMetadata(LLVMContext::MD_tbaa))
>> +      if (TBAATag1 == TBAATag2)
>> +        NewSI->setMetadata(LLVMContext::MD_tbaa, TBAATag1);
>> +
>> +
>>  // Nuke the old stores.
>>  EraseInstFromFunction(SI);
>>  EraseInstFromFunction(*OtherStore);
>> 
>> Modified: llvm/trunk/test/Transforms/InstCombine/store.ll
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/store.ll?rev=171279&r1=171278&r2=171279&view=diff
>> ==============================================================================
>> --- llvm/trunk/test/Transforms/InstCombine/store.ll (original)
>> +++ llvm/trunk/test/Transforms/InstCombine/store.ll Mon Dec 31 02:10:58 2012
>> @@ -83,3 +83,37 @@
>> ; CHECK-NEXT:  ret void
>> }
>> 
>> +
>> +; PR14753 - merging two stores should preserve the TBAA tag.
>> +define void @test6(i32 %n, float* %a, i32* %gi) nounwind uwtable ssp {
>> +entry:
>> +  store i32 42, i32* %gi, align 4, !tbaa !0
>> +  br label %for.cond
>> +
>> +for.cond:                                         ; preds = %for.body, %entry
>> +  %storemerge = phi i32 [ 0, %entry ], [ %inc, %for.body ]
>> +  %0 = load i32* %gi, align 4, !tbaa !0
>> +  %cmp = icmp slt i32 %0, %n
>> +  br i1 %cmp, label %for.body, label %for.end
>> +
>> +for.body:                                         ; preds = %for.cond
>> +  %idxprom = sext i32 %0 to i64
>> +  %arrayidx = getelementptr inbounds float* %a, i64 %idxprom
>> +  store float 0.000000e+00, float* %arrayidx, align 4, !tbaa !3
>> +  %1 = load i32* %gi, align 4, !tbaa !0
>> +  %inc = add nsw i32 %1, 1
>> +  store i32 %inc, i32* %gi, align 4, !tbaa !0
>> +  br label %for.cond
>> +
>> +for.end:                                          ; preds = %for.cond
>> +  ret void
>> +; CHECK: @test6
>> +; CHECK: for.cond:
>> +; CHECK-NEXT: phi i32 [ 42
>> +; CHECK-NEXT: store i32 %storemerge, i32* %gi, align 4, !tbaa !0
>> +}
>> +
>> +!0 = metadata !{metadata !"int", metadata !1}
>> +!1 = metadata !{metadata !"omnipotent char", metadata !2}
>> +!2 = metadata !{metadata !"Simple C/C++ TBAA"}
>> +!3 = metadata !{metadata !"float", metadata !1}
>> 
>> 
>> _______________________________________________
>> 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