Skip to content

Commit 5fa41f0

Browse files
authored
[sroa][profcheck] Propagate select profile (llvm#163317)
1 parent f973d77 commit 5fa41f0

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

llvm/lib/Transforms/Scalar/SROA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1777,7 +1777,7 @@ static void speculateSelectInstLoads(SelectInst &SI, LoadInst &LI,
17771777
}
17781778

17791779
Value *V = IRB.CreateSelect(SI.getCondition(), TL, FL,
1780-
LI.getName() + ".sroa.speculated");
1780+
LI.getName() + ".sroa.speculated", &SI);
17811781

17821782
LLVM_DEBUG(dbgs() << " speculated to: " << *V << "\n");
17831783
LI.replaceAllUsesWith(V);

llvm/test/Transforms/SROA/phi-and-select.ll

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
22
; RUN: opt < %s -passes='sroa<preserve-cfg>' -S | FileCheck %s --check-prefixes=CHECK,CHECK-PRESERVE-CFG
33
; RUN: opt < %s -passes='sroa<modify-cfg>' -S | FileCheck %s --check-prefixes=CHECK,CHECK-MODIFY-CFG
44
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n8:16:32:64"
@@ -36,11 +36,11 @@ exit:
3636
ret i32 %result
3737
}
3838

39-
define i32 @test2() {
39+
define i32 @test2() !prof !0 {
4040
; CHECK-LABEL: @test2(
4141
; CHECK-NEXT: entry:
4242
; CHECK-NEXT: [[COND:%.*]] = icmp sle i32 0, 1
43-
; CHECK-NEXT: [[RESULT_SROA_SPECULATED:%.*]] = select i1 [[COND]], i32 1, i32 0
43+
; CHECK-NEXT: [[RESULT_SROA_SPECULATED:%.*]] = select i1 [[COND]], i32 1, i32 0, !prof [[PROF1:![0-9]+]]
4444
; CHECK-NEXT: ret i32 [[RESULT_SROA_SPECULATED]]
4545
;
4646
entry:
@@ -53,7 +53,7 @@ entry:
5353
%v1 = load i32, ptr %a1
5454

5555
%cond = icmp sle i32 %v0, %v1
56-
%select = select i1 %cond, ptr %a1, ptr %a
56+
%select = select i1 %cond, ptr %a1, ptr %a, !prof !1
5757

5858
%result = load i32, ptr %select
5959
ret i32 %result
@@ -870,3 +870,17 @@ define i8 @volatile_select(ptr %p, i1 %b) {
870870
%v2 = load i8, ptr %px
871871
ret i8 %v2
872872
}
873+
874+
!0 = !{!"function_entry_count", i32 10}
875+
!1 = !{!"branch_weights", i32 3, i32 5}
876+
;.
877+
; CHECK-PRESERVE-CFG: attributes #[[ATTR0:[0-9]+]] = { sanitize_address }
878+
;.
879+
; CHECK-MODIFY-CFG: attributes #[[ATTR0:[0-9]+]] = { sanitize_address }
880+
;.
881+
; CHECK-PRESERVE-CFG: [[META0:![0-9]+]] = !{!"function_entry_count", i32 10}
882+
; CHECK-PRESERVE-CFG: [[PROF1]] = !{!"branch_weights", i32 3, i32 5}
883+
;.
884+
; CHECK-MODIFY-CFG: [[META0:![0-9]+]] = !{!"function_entry_count", i32 10}
885+
; CHECK-MODIFY-CFG: [[PROF1]] = !{!"branch_weights", i32 3, i32 5}
886+
;.

llvm/utils/profcheck-xfail.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,14 +1312,11 @@ Transforms/SimpleLoopUnswitch/pr60736.ll
13121312
Transforms/SimpleLoopUnswitch/trivial-unswitch-freeze-individual-conditions.ll
13131313
Transforms/SimpleLoopUnswitch/trivial-unswitch.ll
13141314
Transforms/SimpleLoopUnswitch/trivial-unswitch-logical-and-or.ll
1315-
Transforms/SROA/addrspacecast.ll
1316-
Transforms/SROA/phi-and-select.ll
13171315
Transforms/SROA/phi-gep.ll
13181316
Transforms/SROA/scalable-vectors-with-known-vscale.ll
13191317
Transforms/SROA/select-gep.ll
13201318
Transforms/SROA/select-load.ll
13211319
Transforms/SROA/slice-width.ll
1322-
Transforms/SROA/std-clamp.ll
13231320
Transforms/SROA/vector-conversion.ll
13241321
Transforms/SROA/vector-promotion-cannot-tree-structure-merge.ll
13251322
Transforms/SROA/vector-promotion.ll

0 commit comments

Comments
 (0)