[polly] ICE with scev-codegen after removal of RegionSimplify
Sebastian Pop
spop at codeaurora.org
Thu May 23 15:00:59 PDT 2013
Sebastian Pop wrote:
> I also have noted several
> new regressions after we removed RegionSimplify. Even in our current testsuite,
> we have an ICE with scev-codegen on: Isl/CodeGen/20110226-PHI-Node-removed.ll
The ICE also occurs before the patch to remove RegionSimplify if we remove the
-region-simplify flag from the testcase. The bug was apparently hidden by the
fact that regionsimplify would create a block before the entry block of the
region "<label>:0" to make the region SESE. Here is the original code:
define void @main() nounwind {
.split:
br label %0
.loopexit: ; preds = %.lr.ph, %0
%indvar.next16 = add i64 %indvar15, 1
%exitcond53 = icmp eq i64 %indvar.next16, 2048
br i1 %exitcond53, label %1, label %0
; <label>:0 ; preds = %.loopexit, %.split
%indvar15 = phi i64 [ 0, %.split ], [ %indvar.next16, %.loopexit ]
%tmp59 = sub i64 2046, %indvar15
%tmp38 = and i64 %tmp59, 4294967295
%tmp39 = add i64 %tmp38, 1
br i1 false, label %.lr.ph, label %.loopexit
.lr.ph: ; preds = %.lr.ph, %0
%indvar33 = phi i64 [ %indvar.next34, %.lr.ph ], [ 0, %0 ]
%indvar.next34 = add i64 %indvar33, 1
%exitcond40 = icmp eq i64 %indvar.next34, %tmp39
br i1 %exitcond40, label %.loopexit, label %.lr.ph
; <label>:1 ; preds = %.loopexit
ret void
}
RegionSimplify would transform the %indvar15 phi node into a phi node with only
one argument (since the region is SESE) and that argument %indvar15.ph will be a
parameter in the region:
(gdb) p R->dump()
[2] %0 => .loopexit
[3] .lr.ph => .loopexit.single_exit
define void @main() #0 {
.split:
br label %.split.split
.split.split: ; preds = %.split
br label %.single_entry
.loopexit.single_exit: ; preds = %0, %.lr.ph
br label %.loopexit
.loopexit: ; preds = %.loopexit.single_exit
%indvar.next16 = add i64 %indvar15, 1
%exitcond53 = icmp eq i64 %indvar.next16, 2048
br i1 %exitcond53, label %1, label %.single_entry
.single_entry: ; preds = %.split.split, %.loopexit
%indvar15.ph = phi i64 [ %indvar.next16, %.loopexit ], [ 0, %.split.split ]
br label %0
; <label>:0 ; preds = %.single_entry
%indvar15 = phi i64 [ %indvar15.ph, %.single_entry ]
%tmp59 = sub i64 2046, %indvar15
%tmp38 = and i64 %tmp59, 4294967295
%tmp39 = add i64 %tmp38, 1
br i1 false, label %.lr.ph, label %.loopexit.single_exit
.lr.ph: ; preds = %.lr.ph, %0
%indvar33 = phi i64 [ %indvar.next34, %.lr.ph ], [ 0, %0 ]
%indvar.next34 = add i64 %indvar33, 1
%exitcond40 = icmp eq i64 %indvar.next34, %tmp39
br i1 %exitcond40, label %.loopexit.single_exit, label %.lr.ph
; <label>:1 ; preds = %.loopexit
ret void
}
After we removed RegionSimplify pass, the code does not get transformed into a
SESE anymore, and so the original phi node %indvar15 will be variant in the
region we detected: so it cannot be detected as before as a parameter.
As IndependenBlocks pass sees that %indvar15 is used outside the region, it will
put %indvar15 on the stack: that confuses SCEV the second time it comes to
analyze %indvar15 to determine the value of %tmp39. That crashes the
IndependenBlocks verifier as %tmp39 is used in a different BB and it does not
have a known SCEV, whereas during the IndependenBlocks transform %tmp39 had a
known SCEV.
I'm not yet sure how to fix the problem. I think it is good to speak about the
fix before coding something.
Thanks,
Sebastian
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
More information about the llvm-commits
mailing list