diff options
author | Nicolai Haehnle <nhaehnle@gmail.com> | 2018-02-23 10:45:46 +0000 |
---|---|---|
committer | Nicolai Haehnle <nhaehnle@gmail.com> | 2018-02-23 10:45:46 +0000 |
commit | 43c1115cd461c1ed6bf5e599eedb17ed64b87c47 (patch) | |
tree | 4609cb8c43e53b21222ce3ffb466e254167bce36 /llvm/lib/Transforms/Scalar/StructurizeCFG.cpp | |
parent | 983d6c3f18908532b28887ca96ac0da6ad921e7f (diff) | |
download | bcm5719-llvm-43c1115cd461c1ed6bf5e599eedb17ed64b87c47.tar.gz bcm5719-llvm-43c1115cd461c1ed6bf5e599eedb17ed64b87c47.zip |
StructurizeCFG: Test for branch divergence correctly
Summary:
This fixes cases like the new test @nonuniform. In that test, %cc itself
is a uniform value; however, when reading it after the end of the loop in
basic block %if, its value is effectively non-uniform.
This problem was encountered in
https://bugs.freedesktop.org/show_bug.cgi?id=103743; however, this change
in itself is not sufficient to fix that bug, as there is another issue
in the AMDGPU backend.
Change-Id: I32bbffece4a32f686fab54964dae1a5dd72949d4
Reviewers: arsenm, rampitec, jlebar
Subscribers: wdng, tpr, llvm-commits
Differential Revision: https://reviews.llvm.org/D40546
llvm-svn: 325881
Diffstat (limited to 'llvm/lib/Transforms/Scalar/StructurizeCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/StructurizeCFG.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp index b8fb80b6cc2..dc4d1f73f87 100644 --- a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp +++ b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp @@ -55,6 +55,12 @@ static const char *const FlowBlockName = "Flow"; namespace { +static cl::opt<bool> ForceSkipUniformRegions( + "structurizecfg-skip-uniform-regions", + cl::Hidden, + cl::desc("Force whether the StructurizeCFG pass skips uniform regions"), + cl::init(false)); + // Definition of the complex types used in this pass. using BBValuePair = std::pair<BasicBlock *, Value *>; @@ -242,8 +248,11 @@ class StructurizeCFG : public RegionPass { public: static char ID; - explicit StructurizeCFG(bool SkipUniformRegions = false) - : RegionPass(ID), SkipUniformRegions(SkipUniformRegions) { + explicit StructurizeCFG(bool SkipUniformRegions_ = false) + : RegionPass(ID), + SkipUniformRegions(SkipUniformRegions_) { + if (ForceSkipUniformRegions.getNumOccurrences()) + SkipUniformRegions = ForceSkipUniformRegions.getValue(); initializeStructurizeCFGPass(*PassRegistry::getPassRegistry()); } @@ -885,7 +894,7 @@ static bool hasOnlyUniformBranches(const Region *R, if (!Br || !Br->isConditional()) continue; - if (!DA.isUniform(Br->getCondition())) + if (!DA.isUniform(Br)) return false; DEBUG(dbgs() << "BB: " << BB->getName() << " has uniform terminator\n"); } |