-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Labels
llvm:analysisIncludes value tracking, cost tables and constant foldingIncludes value tracking, cost tables and constant folding
Description
Input:
define void @f(ptr %a, i64 %k) {
entry:
br label %loop
loop:
%i = phi i64 [ 0, %entry ], [ %i.next, %loop ]
%subscript = mul i64 %i, %k
%idx = getelementptr i8, ptr %a, i64 %subscript
store i8 42, ptr %idx
%i.next = add i64 %i, 1
%cond.exit = icmp eq i64 %i.next, 100
br i1 %cond.exit, label %exit, label %loop
exit:
ret void
}Result:
$ opt -passes='print<da>' -disable-output test.ll
Printing analysis 'Dependence Analysis' for function 'f':
Src: store i8 42, ptr %idx, align 1 --> Dst: store i8 42, ptr %idx, align 1
da analyze - none!
godbolt: https://godbolt.org/z/6eq4W84q5
This is incorrect when %k is zero, where the store accesses the same memory location in all iterations. At first glance, it seems that some routines in DA assume that the coefficient of the subscript is non-zero, which is not always the case.
Metadata
Metadata
Assignees
Labels
llvm:analysisIncludes value tracking, cost tables and constant foldingIncludes value tracking, cost tables and constant folding