blob: 6cab270cb411d55040026504b68c61a8d99df6cb [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -disable-output "-passes=print<da>" 2>&1 \
; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-ALL
;
; for (i = 0; i < 2; i++) {
; A[-2] = 0;
; for (j = 0; j < 2; j++) {
; if (i == j)
; A[INT64_MAX*i + INT64_MAX*j] = 1;
; }
; }
;
; There is a dependency between the two stores.
;
; memory access | (i, j) == (1, 1)
; ------------------------------|------------------
; A[-2] | A[-2]
; A[INT64_MAX*i + INT64_MAX*j] | A[-2]
;
; Previously, this dependency was missed because RDIV performs "minor algebra"
; and transforms the subscripts as follows:
;
; A[-2] and A[INT64_MAX*i + INT64_MAX*j]
;
; | minor algebra
; v
;
; A[-INT64_MAX*j - 2] and A[INT64_MAX*i]
;
; This is unsound.
;
define void @f(ptr %A) {
; CHECK-LABEL: 'f'
; CHECK-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 0, ptr %gep.0, align 1
; CHECK-NEXT: da analyze - output [S]!
; CHECK-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.1, align 1
; CHECK-NEXT: da analyze - output [*|<]!
; CHECK-NEXT: Src: store i8 1, ptr %gep.1, align 1 --> Dst: store i8 1, ptr %gep.1, align 1
; CHECK-NEXT: da analyze - output [* *]!
;
entry:
br label %loop.i.header
loop.i.header:
%i = phi i64 [ 0, %entry ], [ %i.inc, %loop.i.latch ]
%i.mul = mul i64 %i, 9223372036854775807
%gep.0 = getelementptr i8, ptr %A, i64 -2
store i8 0, ptr %gep.0
br label %loop.j.header
loop.j.header:
%j = phi i64 [ 0, %loop.i.header ], [ %j.inc, %loop.j.latch ]
%j.mul = mul i64 %j, 9223372036854775807
%offset.tmp = add i64 %i.mul, %j.mul
%offset = add i64 %offset.tmp, -2
%cond = icmp eq i64 %i, %j
br i1 %cond, label %if.then, label %loop.j.latch
if.then:
%gep.1 = getelementptr i8, ptr %A, i64 %offset
store i8 1, ptr %gep.1
br label %loop.j.latch
loop.j.latch:
%j.inc = add i64 %j, 1
%ec.j = icmp eq i64 %j.inc, 2
br i1 %ec.j, label %loop.i.latch, label %loop.j.header
loop.i.latch:
%i.inc = add i64 %i, 1
%ec.i = icmp eq i64 %i.inc, 2
br i1 %ec.i, label %exit, label %loop.i.header
exit:
ret void
}
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; CHECK-ALL: {{.*}}