mirror of
https://github.com/RPCS3/llvm.git
synced 2026-01-31 01:25:19 +01:00
Summary:
Motivation: fix PR31181 without regression (the actual fix is still in
progress). However, the actual content of PR31181 is not relevant
here.
This change makes poison propagation more aggressive in the following
cases:
1. poision * Val == poison, for any Val. In particular, this changes
existing intentional and documented behavior in these two cases:
a. Val is 0
b. Val is 2^k * N
2. poison << Val == poison, for any Val
3. getelementptr is poison if any input is poison
I think all of these are justified (and are axiomatically true in the
new poison / undef model):
1a: we need poison * 0 to be poison to allow transforms like these:
A * (B + C) ==> A * B + A * C
If poison * 0 were 0 then the above transform could not be allowed
since e.g. we could have A = poison, B = 1, C = -1, making the LHS
poison * (1 + -1) = poison * 0 = 0
and the RHS
poison * 1 + poison * -1 = poison + poison = poison
1b: we need e.g. poison * 4 to be poison since we want to allow
A * 4 ==> A + A + A + A
If poison * 4 were a value with all of their bits poison except the
last four; then we'd not be able to do this transform since then if A
were poison the LHS would only be "partially" poison while the RHS
would be "full" poison.
2: Same reasoning as (1b), we'd like have the following kinds
transforms be legal:
A << 1 ==> A + A
Reviewers: majnemer, efriedma
Subscribers: mcrosier, llvm-commits
Differential Revision: https://reviews.llvm.org/D30185
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295809 91177308-0d34-0410-b5e6-96231b3b80d8
64 lines
2.6 KiB
LLVM
64 lines
2.6 KiB
LLVM
; RUN: opt < %s -analyze -delinearize | FileCheck %s
|
|
;
|
|
; void foo(long n, long m, long o, int A[n][m][o]) {
|
|
; for (long i = 0; i < n; i++)
|
|
; for (long j = 0; j < m; j++)
|
|
; for (long k = 0; k < o; k++)
|
|
; A[2*i+3][3*j-4][5*k+7] = 1;
|
|
; }
|
|
|
|
; AddRec: {{{(28 + (4 * (-4 + (3 * %m)) * %o) + %A),+,(8 * %m * %o)}<%for.i>,+,(12 * %o)}<%for.j>,+,20}<%for.k>
|
|
; CHECK: Base offset: %A
|
|
; CHECK: ArrayDecl[UnknownSize][%m][%o] with elements of 4 bytes.
|
|
; CHECK: ArrayRef[{3,+,2}<%for.i>][{-4,+,3}<nw><%for.j>][{7,+,5}<nw><%for.k>]
|
|
|
|
define void @foo(i64 %n, i64 %m, i64 %o, i32* nocapture %A) #0 {
|
|
entry:
|
|
%cmp32 = icmp sgt i64 %n, 0
|
|
br i1 %cmp32, label %for.cond1.preheader.lr.ph, label %for.end17
|
|
|
|
for.cond1.preheader.lr.ph: ; preds = %entry
|
|
%cmp230 = icmp sgt i64 %m, 0
|
|
%cmp528 = icmp sgt i64 %o, 0
|
|
br i1 %cmp230, label %for.i, label %for.end17
|
|
|
|
for.inc15.us: ; preds = %for.inc12.us.us, %for.i
|
|
%inc16.us = add nsw i64 %i.033.us, 1
|
|
%exitcond55 = icmp eq i64 %inc16.us, %n
|
|
br i1 %exitcond55, label %for.end17, label %for.i
|
|
|
|
for.i: ; preds = %for.cond1.preheader.lr.ph, %for.inc15.us
|
|
%i.033.us = phi i64 [ %inc16.us, %for.inc15.us ], [ 0, %for.cond1.preheader.lr.ph ]
|
|
%mul8.us = shl i64 %i.033.us, 1
|
|
%add9.us = add nsw i64 %mul8.us, 3
|
|
%0 = mul i64 %add9.us, %m
|
|
%sub.us = add i64 %0, -4
|
|
br i1 %cmp528, label %for.j, label %for.inc15.us
|
|
|
|
for.inc12.us.us: ; preds = %for.k
|
|
%inc13.us.us = add nsw i64 %j.031.us.us, 1
|
|
%exitcond54 = icmp eq i64 %inc13.us.us, %m
|
|
br i1 %exitcond54, label %for.inc15.us, label %for.j
|
|
|
|
for.j: ; preds = %for.i, %for.inc12.us.us
|
|
%j.031.us.us = phi i64 [ %inc13.us.us, %for.inc12.us.us ], [ 0, %for.i ]
|
|
%mul7.us.us = mul nsw i64 %j.031.us.us, 3
|
|
%tmp.us.us = add i64 %sub.us, %mul7.us.us
|
|
%tmp27.us.us = mul i64 %tmp.us.us, %o
|
|
br label %for.k
|
|
|
|
for.k: ; preds = %for.k, %for.j
|
|
%k.029.us.us = phi i64 [ 0, %for.j ], [ %inc.us.us, %for.k ]
|
|
%mul.us.us = mul nsw i64 %k.029.us.us, 5
|
|
%arrayidx.sum.us.us = add i64 %mul.us.us, 7
|
|
%arrayidx10.sum.us.us = add i64 %arrayidx.sum.us.us, %tmp27.us.us
|
|
%arrayidx11.us.us = getelementptr inbounds i32, i32* %A, i64 %arrayidx10.sum.us.us
|
|
store i32 1, i32* %arrayidx11.us.us, align 4
|
|
%inc.us.us = add nsw i64 %k.029.us.us, 1
|
|
%exitcond = icmp eq i64 %inc.us.us, %o
|
|
br i1 %exitcond, label %for.inc12.us.us, label %for.k
|
|
|
|
for.end17: ; preds = %for.inc15.us, %for.cond1.preheader.lr.ph, %entry
|
|
ret void
|
|
}
|