Open Quuxplusone opened 8 years ago
Bugzilla Link | PR27838 |
Status | NEW |
Importance | P normal |
Reported by | Chengnian Sun (chengniansun@gmail.com) |
Reported on | 2016-05-22 22:52:41 -0700 |
Last modified on | 2016-08-03 17:54:52 -0700 |
Version | trunk |
Hardware | PC All |
CC | hans@chromium.org, hfinkel@anl.gov, llvm-bugs@lists.llvm.org, michael.v.zolotukhin@gmail.com, sanjoy@playingwithpointers.com |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
Looks like the problem is in simplifyLoop function.
It doesn't always preserve LCSSA form, namely a call to
FoldBranchToCommonDest(BI) destroys it in the provided testcase
(LoopSimplify.cpp:661). The following patch fixes the issue:
diff --git a/lib/Transforms/Utils/LoopSimplify.cpp
b/lib/Transforms/Utils/LoopSimplify.cpp
index 63d4a04..fb5282c 100644
--- a/lib/Transforms/Utils/LoopSimplify.cpp
+++ b/lib/Transforms/Utils/LoopSimplify.cpp
@@ -658,7 +658,7 @@ ReprocessLoop:
// The block has now been cleared of all instructions except for
// a comparison and a conditional branch. SimplifyCFG may be able
// to fold it now.
- if (!FoldBranchToCommonDest(BI))
+ if (PreserveLCSSA || !FoldBranchToCommonDest(BI))
continue;
// Success. The block is now dead, so remove it from the loop,
I'm having troubles with writing a testcase for this though, probably becuase
of implicit dependencies that, when run, fix-up the test.
I can't reproruce this on 3.9 or trunk. Is it fixed?
I didn't commit the patch.
My guess is that the bug might be still there, but now it's concealed. I'll take another look at this soon.