[llvm] a04ab2e - [Pipeliner] Fix the bug in pragma that disables the pipeliner.

Sumanth Gundapaneni via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 10 10:52:39 PDT 2020


Author: Sumanth Gundapaneni
Date: 2020-04-10T12:52:16-05:00
New Revision: a04ab2ec08014d36337d686d43ecef7668622f1b

URL: https://github.com/llvm/llvm-project/commit/a04ab2ec08014d36337d686d43ecef7668622f1b
DIFF: https://github.com/llvm/llvm-project/commit/a04ab2ec08014d36337d686d43ecef7668622f1b.diff

LOG: [Pipeliner] Fix the bug in pragma that disables the pipeliner.

Differential Revision: https://reviews.llvm.org/D76303.

Added: 
    llvm/test/CodeGen/Hexagon/swp-pragma-disable-bug.ll

Modified: 
    llvm/lib/CodeGen/MachinePipeliner.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp
index 41a53d1edde6..efb44054096c 100644
--- a/llvm/lib/CodeGen/MachinePipeliner.cpp
+++ b/llvm/lib/CodeGen/MachinePipeliner.cpp
@@ -259,6 +259,9 @@ bool MachinePipeliner::scheduleLoop(MachineLoop &L) {
 }
 
 void MachinePipeliner::setPragmaPipelineOptions(MachineLoop &L) {
+  // Reset the pragma for the next loop in iteration.
+  disabledByPragma = false;
+
   MachineBasicBlock *LBLK = L.getTopBlock();
 
   if (LBLK == nullptr)

diff  --git a/llvm/test/CodeGen/Hexagon/swp-pragma-disable-bug.ll b/llvm/test/CodeGen/Hexagon/swp-pragma-disable-bug.ll
new file mode 100644
index 000000000000..63c0f9502ee2
--- /dev/null
+++ b/llvm/test/CodeGen/Hexagon/swp-pragma-disable-bug.ll
@@ -0,0 +1,57 @@
+; RUN: llc -O2 -march=hexagon -enable-pipeliner  \
+; RUN: -debug-only=pipeliner < %s 2>&1 > /dev/null | FileCheck %s
+; REQUIRES: asserts
+;
+; Test that the pragma check that disables pipeliner does not disable pipelining
+; on both the loops.
+; CHECK: Can not pipeline loop
+; CHECK-NOT: Can not pipeline loop
+
+; Function Attrs: nofree norecurse nounwind
+define dso_local i32 @foo(i32* nocapture %a, i32* nocapture readonly %b, i32* nocapture %c) local_unnamed_addr #0 {
+entry:
+  br label %for.body
+
+for.body:                                         ; preds = %for.body, %entry
+  %i.023 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
+  %arrayidx = getelementptr inbounds i32, i32* %b, i32 %i.023
+  %0 = load i32, i32* %arrayidx, align 4, !tbaa !2
+  %arrayidx1 = getelementptr inbounds i32, i32* %a, i32 %i.023
+  %1 = load i32, i32* %arrayidx1, align 4, !tbaa !2
+  %add = add nsw i32 %1, %0
+  store i32 %add, i32* %arrayidx1, align 4, !tbaa !2
+  %inc = add nuw nsw i32 %i.023, 1
+  %exitcond24 = icmp eq i32 %inc, 10
+  br i1 %exitcond24, label %for.body6, label %for.body, !llvm.loop !6
+
+for.cond.cleanup5:                                ; preds = %for.body6
+  ret i32 0
+
+for.body6:                                        ; preds = %for.body, %for.body6
+  %i2.022 = phi i32 [ %inc11, %for.body6 ], [ 0, %for.body ]
+  %arrayidx7 = getelementptr inbounds i32, i32* %a, i32 %i2.022
+  %2 = load i32, i32* %arrayidx7, align 4, !tbaa !2
+  %arrayidx8 = getelementptr inbounds i32, i32* %c, i32 %i2.022
+  %3 = load i32, i32* %arrayidx8, align 4, !tbaa !2
+  %add9 = add nsw i32 %3, %2
+  store i32 %add9, i32* %arrayidx8, align 4, !tbaa !2
+  %inc11 = add nuw nsw i32 %i2.022, 1
+  %exitcond = icmp eq i32 %inc11, 10
+  br i1 %exitcond, label %for.cond.cleanup5, label %for.body6, !llvm.loop !8
+}
+
+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" }
+
+!llvm.module.flags = !{!0}
+!llvm.ident = !{!1}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 6e29846b29d2bcaa8a7a3d869f24f242bd93d272)"}
+!2 = !{!3, !3, i64 0}
+!3 = !{!"int", !4, i64 0}
+!4 = !{!"omnipotent char", !5, i64 0}
+!5 = !{!"Simple C/C++ TBAA"}
+!6 = distinct !{!6, !7}
+!7 = !{!"llvm.loop.unroll.disable"}
+!8 = distinct !{!8, !7, !9}
+!9 = !{!"llvm.loop.pipeline.disable", i1 true}


        


More information about the llvm-commits mailing list