Skip to content

Commit a04ab2e

Browse files
author
Sumanth Gundapaneni
committed
[Pipeliner] Fix the bug in pragma that disables the pipeliner.
Differential Revision: https://reviews.llvm.org/D76303.
1 parent bef187c commit a04ab2e

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

llvm/lib/CodeGen/MachinePipeliner.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ bool MachinePipeliner::scheduleLoop(MachineLoop &L) {
259259
}
260260

261261
void MachinePipeliner::setPragmaPipelineOptions(MachineLoop &L) {
262+
// Reset the pragma for the next loop in iteration.
263+
disabledByPragma = false;
264+
262265
MachineBasicBlock *LBLK = L.getTopBlock();
263266

264267
if (LBLK == nullptr)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
; RUN: llc -O2 -march=hexagon -enable-pipeliner \
2+
; RUN: -debug-only=pipeliner < %s 2>&1 > /dev/null | FileCheck %s
3+
; REQUIRES: asserts
4+
;
5+
; Test that the pragma check that disables pipeliner does not disable pipelining
6+
; on both the loops.
7+
; CHECK: Can not pipeline loop
8+
; CHECK-NOT: Can not pipeline loop
9+
10+
; Function Attrs: nofree norecurse nounwind
11+
define dso_local i32 @foo(i32* nocapture %a, i32* nocapture readonly %b, i32* nocapture %c) local_unnamed_addr #0 {
12+
entry:
13+
br label %for.body
14+
15+
for.body: ; preds = %for.body, %entry
16+
%i.023 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
17+
%arrayidx = getelementptr inbounds i32, i32* %b, i32 %i.023
18+
%0 = load i32, i32* %arrayidx, align 4, !tbaa !2
19+
%arrayidx1 = getelementptr inbounds i32, i32* %a, i32 %i.023
20+
%1 = load i32, i32* %arrayidx1, align 4, !tbaa !2
21+
%add = add nsw i32 %1, %0
22+
store i32 %add, i32* %arrayidx1, align 4, !tbaa !2
23+
%inc = add nuw nsw i32 %i.023, 1
24+
%exitcond24 = icmp eq i32 %inc, 10
25+
br i1 %exitcond24, label %for.body6, label %for.body, !llvm.loop !6
26+
27+
for.cond.cleanup5: ; preds = %for.body6
28+
ret i32 0
29+
30+
for.body6: ; preds = %for.body, %for.body6
31+
%i2.022 = phi i32 [ %inc11, %for.body6 ], [ 0, %for.body ]
32+
%arrayidx7 = getelementptr inbounds i32, i32* %a, i32 %i2.022
33+
%2 = load i32, i32* %arrayidx7, align 4, !tbaa !2
34+
%arrayidx8 = getelementptr inbounds i32, i32* %c, i32 %i2.022
35+
%3 = load i32, i32* %arrayidx8, align 4, !tbaa !2
36+
%add9 = add nsw i32 %3, %2
37+
store i32 %add9, i32* %arrayidx8, align 4, !tbaa !2
38+
%inc11 = add nuw nsw i32 %i2.022, 1
39+
%exitcond = icmp eq i32 %inc11, 10
40+
br i1 %exitcond, label %for.cond.cleanup5, label %for.body6, !llvm.loop !8
41+
}
42+
43+
attributes #0 = { nofree norecurse nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="hexagonv60" "target-features"="+v60,-long-calls" "unsafe-fp-math"="false" "use-soft-float"="false" }
44+
45+
!llvm.module.flags = !{!0}
46+
!llvm.ident = !{!1}
47+
48+
!0 = !{i32 1, !"wchar_size", i32 4}
49+
!1 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 6e29846b29d2bcaa8a7a3d869f24f242bd93d272)"}
50+
!2 = !{!3, !3, i64 0}
51+
!3 = !{!"int", !4, i64 0}
52+
!4 = !{!"omnipotent char", !5, i64 0}
53+
!5 = !{!"Simple C/C++ TBAA"}
54+
!6 = distinct !{!6, !7}
55+
!7 = !{!"llvm.loop.unroll.disable"}
56+
!8 = distinct !{!8, !7, !9}
57+
!9 = !{!"llvm.loop.pipeline.disable", i1 true}

0 commit comments

Comments
 (0)