[PATCH] D149331: [LCSSA] Don't invalidate entire loop in SCEV
Vasileios Porpodas via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 1 10:39:37 PDT 2023
vporpo added a comment.
Hi, these changes that remove SCEV invalidation from LCSSA are causing compiler crashes:
5362a0d859d8 [LCSSA] Remove unused ScalarEvolution argument (NFC)
5cbb9f7a58d9 [LCSSA] Don't invalidate SCEV
0aed0dbec243 [LCSSA] Don't invalidate entire loop in SCEV
The incorrect code is generated by the SCEV expander. Here is a reproducer:
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-grtev4-linux-gnu"
define i32 @f(i1 %cond1) #0 !prof !0 {
entry:
br label %loop1
loop1:
%ld = load i64, ptr null, align 8
br i1 %cond1, label %loop1, label %exit1, !prof !1
exit1:
br label %entry2
entry2:
br label %loop2
loop2:
%phi = phi i64 [ 0, %entry2 ], [ %inc, %loop2 ]
%inc = add i64 %phi, 1
%gep = getelementptr [268435454 x ptr], ptr null, i64 %phi
store ptr null, ptr %gep, align 8
store ptr null, ptr null, align 8
%cond2 = icmp eq i64 %ld, %phi
br i1 %cond2, label %exit2, label %loop2
exit2:
ret i32 0
}
attributes #0 = { "target-cpu"="haswell" }
!0 = !{!"function_entry_count", i64 1}
!1 = !{!"branch_weights", i32 123, i32 472}
Run: `opt -p 'slp-vectorizer,loop-unroll' `.
This is the output of the crash:
Instruction does not dominate all uses!
%ld.lcssa2 = phi i64 [ %ld, %loop1 ]
%0 = add i64 %ld.lcssa2, 1
Instruction does not dominate all uses!
%ld.lcssa2 = phi i64 [ %ld, %loop1 ]
%1 = icmp ult i64 %ld.lcssa2, 7
LLVM ERROR: Broken module found, compilation aborted!
SLP is just creating some SCEV objects and is not modifying the code at all. SCEV seems to go stale after LCSSA, so the SCEV expander in `LoopUnrollRuntime.cpp:747` is generating incorrect code.
Could you please take a look and revert the patches if this is not an easy fix?
Thanks!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149331/new/
https://reviews.llvm.org/D149331
More information about the llvm-commits
mailing list