From: Sanjay Patel Date: Sat, 26 Mar 2016 23:30:50 +0000 (+0000) Subject: [SimplifyCFG] propagate branch metadata when creating select (PR26636) X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=796db35f622d0730347a09a9b675bc5e113db9c3;p=platform%2Fupstream%2Fllvm.git [SimplifyCFG] propagate branch metadata when creating select (PR26636) llvm-svn: 264527 --- diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 7d210e6..75d4261 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1642,8 +1642,8 @@ static bool SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *ThenBB, Value *FalseV = SpeculatedStoreValue; if (Invert) std::swap(TrueV, FalseV); - Value *S = Builder.CreateSelect(BrCond, TrueV, FalseV, TrueV->getName() + - "." + FalseV->getName()); + Value *S = Builder.CreateSelect( + BrCond, TrueV, FalseV, TrueV->getName() + "." + FalseV->getName(), BI); SpeculatedStore->setOperand(0, S); } diff --git a/llvm/test/Transforms/SimplifyCFG/speculate-store.ll b/llvm/test/Transforms/SimplifyCFG/speculate-store.ll index 15f403c..497e024 100644 --- a/llvm/test/Transforms/SimplifyCFG/speculate-store.ll +++ b/llvm/test/Transforms/SimplifyCFG/speculate-store.ll @@ -4,7 +4,7 @@ define void @ifconvertstore(i32* %A, i32 %B, i32 %C, i32 %D) { ; CHECK-LABEL: @ifconvertstore( ; CHECK: store i32 %B, i32* %A ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 %D, 42 -; CHECK-NEXT: [[C_B:%.*]] = select i1 [[CMP]], i32 %C, i32 %B +; CHECK-NEXT: [[C_B:%.*]] = select i1 [[CMP]], i32 %C, i32 %B, !prof !0 ; CHECK-NEXT: store i32 [[C_B]], i32* %A ; CHECK-NEXT: ret void ; @@ -12,7 +12,7 @@ entry: ; First store to the location. store i32 %B, i32* %A %cmp = icmp sgt i32 %D, 42 - br i1 %cmp, label %if.then, label %ret.end + br i1 %cmp, label %if.then, label %ret.end, !prof !0 ; Make sure we speculate stores like the following one. It is cheap compared to ; a mispredicated branch. @@ -85,3 +85,6 @@ ret.end: ret void } +; CHECK: !0 = !{!"branch_weights", i32 3, i32 5} +!0 = !{!"branch_weights", i32 3, i32 5} +