[llvm] r264527 - [SimplifyCFG] propagate branch metadata when creating select (PR26636)

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 26 16:30:50 PDT 2016


Author: spatel
Date: Sat Mar 26 18:30:50 2016
New Revision: 264527

URL: http://llvm.org/viewvc/llvm-project?rev=264527&view=rev
Log:
[SimplifyCFG] propagate branch metadata when creating select (PR26636)

Modified:
    llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
    llvm/trunk/test/Transforms/SimplifyCFG/speculate-store.ll

Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=264527&r1=264526&r2=264527&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Sat Mar 26 18:30:50 2016
@@ -1642,8 +1642,8 @@ static bool SpeculativelyExecuteBB(Branc
     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);
   }
 

Modified: llvm/trunk/test/Transforms/SimplifyCFG/speculate-store.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/speculate-store.ll?rev=264527&r1=264526&r2=264527&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyCFG/speculate-store.ll (original)
+++ llvm/trunk/test/Transforms/SimplifyCFG/speculate-store.ll Sat Mar 26 18:30:50 2016
@@ -4,7 +4,7 @@ define void @ifconvertstore(i32* %A, i32
 ; 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}
+




More information about the llvm-commits mailing list