[ScopDetect] Evaluate and verify branches at branch condition, not icmp
authorTobias Grosser <tobias@grosser.es>
Sun, 13 Nov 2016 19:27:04 +0000 (19:27 +0000)
committerTobias Grosser <tobias@grosser.es>
Sun, 13 Nov 2016 19:27:04 +0000 (19:27 +0000)
commita2f8fa33aa21f617312ae4cbaefb3c5823355128
treef2c4fad202d3e6dd8830de5e0f4fa8e6da50e09c
parent987dad2bc37e16c8f84c0a51ec5d063c35592f5a
[ScopDetect] Evaluate and verify branches at branch condition, not icmp

The validity of a branch condition must be verified at the location of the
branch (the branch instruction), not the location of the icmp that is
used in the branch instruction. When verifying at the wrong location, we
may accept an icmp that is defined within a loop which itself dominates, but
does not contain the branch instruction. Such loops cannot be modeled as
we only introduce domain dimensions for surrounding loops. To address this
problem we change the scop detection to evaluate and verify SCEV expressions at
the right location.

This issue has been around since at least r179148 "scop detection: properly
instantiate SCEVs to the place where they are used", where we explicitly
set the scope to the wrong location. Before this commit the scope
was not explicitly set, which probably also resulted in the scope around the
ICmp to be choosen.

This resolves http://llvm.org/PR30989

Reported-by: Eli Friedman <efriedma@codeaurora.org>
llvm-svn: 286769
polly/lib/Analysis/ScopDetection.cpp
polly/test/ScopInfo/branch-references-loop-scev-with-unknown-iterations-2.ll [new file with mode: 0644]
polly/test/ScopInfo/branch-references-loop-scev-with-unknown-iterations-3.ll [new file with mode: 0644]
polly/test/ScopInfo/branch-references-loop-scev-with-unknown-iterations.ll [new file with mode: 0644]