Skip to content

Commit 48a70c1

Browse files
committed
Revert "[DA] Check for overflow in strong SIV test (llvm#164704)"
This reverts commit 1b3e7df.
1 parent 1b3e7df commit 48a70c1

File tree

3 files changed

+17
-90
lines changed

3 files changed

+17
-90
lines changed

llvm/lib/Analysis/DependenceAnalysis.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,15 +1587,6 @@ static const SCEV *minusSCEVNoSignedOverflow(const SCEV *A, const SCEV *B,
15871587
return nullptr;
15881588
}
15891589

1590-
/// Returns \p A * \p B if it guaranteed not to signed wrap. Otherwise returns
1591-
/// nullptr. \p A and \p B must have the same integer type.
1592-
static const SCEV *mulSCEVNoSignedOverflow(const SCEV *A, const SCEV *B,
1593-
ScalarEvolution &SE) {
1594-
if (SE.willNotOverflow(Instruction::Mul, /*Signed=*/true, A, B))
1595-
return SE.getMulExpr(A, B);
1596-
return nullptr;
1597-
}
1598-
15991590
/// Returns the absolute value of \p A. In the context of dependence analysis,
16001591
/// we need an absolute value in a mathematical sense. If \p A is the signed
16011592
/// minimum value, we cannot represent it unless extending the original type.
@@ -1695,11 +1686,7 @@ bool DependenceInfo::strongSIVtest(const SCEV *Coeff, const SCEV *SrcConst,
16951686
assert(0 < Level && Level <= CommonLevels && "level out of range");
16961687
Level--;
16971688

1698-
const SCEV *Delta = minusSCEVNoSignedOverflow(SrcConst, DstConst, *SE);
1699-
if (!Delta) {
1700-
Result.Consistent = false;
1701-
return false;
1702-
}
1689+
const SCEV *Delta = SE->getMinusSCEV(SrcConst, DstConst);
17031690
LLVM_DEBUG(dbgs() << "\t Delta = " << *Delta);
17041691
LLVM_DEBUG(dbgs() << ", " << *Delta->getType() << "\n");
17051692

@@ -1715,9 +1702,7 @@ bool DependenceInfo::strongSIVtest(const SCEV *Coeff, const SCEV *SrcConst,
17151702
const SCEV *AbsCoeff = absSCEVNoSignedOverflow(Coeff, *SE);
17161703
if (!AbsDelta || !AbsCoeff)
17171704
return false;
1718-
const SCEV *Product = mulSCEVNoSignedOverflow(UpperBound, AbsCoeff, *SE);
1719-
if (!Product)
1720-
return false;
1705+
const SCEV *Product = SE->getMulExpr(UpperBound, AbsCoeff);
17211706
return isKnownPredicate(CmpInst::ICMP_SGT, AbsDelta, Product);
17221707
}();
17231708
if (IsDeltaLarge) {

llvm/test/Analysis/DependenceAnalysis/SimpleSIVNoValidityCheck.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ define void @t3(i64 %n, i64 %m, i64 %lb, ptr %a) {
210210
; CHECK-NEXT: Src: %2 = load i32, ptr %arrayidx6, align 4 --> Dst: %2 = load i32, ptr %arrayidx6, align 4
211211
; CHECK-NEXT: da analyze - none!
212212
; CHECK-NEXT: Src: %2 = load i32, ptr %arrayidx6, align 4 --> Dst: store i32 %2, ptr %arrayidx8, align 4
213-
; CHECK-NEXT: da analyze - anti [1 *]!
213+
; CHECK-NEXT: da analyze - consistent anti [1 -2]!
214214
; CHECK-NEXT: Src: store i32 %2, ptr %arrayidx8, align 4 --> Dst: store i32 %2, ptr %arrayidx8, align 4
215215
; CHECK-NEXT: da analyze - none!
216216
;

llvm/test/Analysis/DependenceAnalysis/StrongSIV.ll

Lines changed: 14 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 5
22
; RUN: opt < %s -disable-output "-passes=print<da>" -aa-pipeline=basic-aa 2>&1 \
3-
; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-ALL
4-
; RUN: opt < %s -disable-output "-passes=print<da>" -aa-pipeline=basic-aa -da-enable-dependence-test=strong-siv 2>&1 \
5-
; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-STRONG-SIV
3+
; RUN: | FileCheck %s
64

75
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
86
target triple = "x86_64-apple-macosx10.6.0"
@@ -425,33 +423,19 @@ for.end: ; preds = %for.body
425423
;; *B++ = A[i + 2*n];
426424

427425
define void @strong9(ptr %A, ptr %B, i64 %n) nounwind uwtable ssp {
428-
; CHECK-ALL-LABEL: 'strong9'
429-
; CHECK-ALL-NEXT: Src: store i32 %conv, ptr %arrayidx, align 4 --> Dst: store i32 %conv, ptr %arrayidx, align 4
430-
; CHECK-ALL-NEXT: da analyze - none!
431-
; CHECK-ALL-NEXT: Src: store i32 %conv, ptr %arrayidx, align 4 --> Dst: %0 = load i32, ptr %arrayidx2, align 4
432-
; CHECK-ALL-NEXT: da analyze - none!
433-
; CHECK-ALL-NEXT: Src: store i32 %conv, ptr %arrayidx, align 4 --> Dst: store i32 %0, ptr %B.addr.02, align 4
434-
; CHECK-ALL-NEXT: da analyze - confused!
435-
; CHECK-ALL-NEXT: Src: %0 = load i32, ptr %arrayidx2, align 4 --> Dst: %0 = load i32, ptr %arrayidx2, align 4
436-
; CHECK-ALL-NEXT: da analyze - none!
437-
; CHECK-ALL-NEXT: Src: %0 = load i32, ptr %arrayidx2, align 4 --> Dst: store i32 %0, ptr %B.addr.02, align 4
438-
; CHECK-ALL-NEXT: da analyze - confused!
439-
; CHECK-ALL-NEXT: Src: store i32 %0, ptr %B.addr.02, align 4 --> Dst: store i32 %0, ptr %B.addr.02, align 4
440-
; CHECK-ALL-NEXT: da analyze - none!
441-
;
442-
; CHECK-STRONG-SIV-LABEL: 'strong9'
443-
; CHECK-STRONG-SIV-NEXT: Src: store i32 %conv, ptr %arrayidx, align 4 --> Dst: store i32 %conv, ptr %arrayidx, align 4
444-
; CHECK-STRONG-SIV-NEXT: da analyze - none!
445-
; CHECK-STRONG-SIV-NEXT: Src: store i32 %conv, ptr %arrayidx, align 4 --> Dst: %0 = load i32, ptr %arrayidx2, align 4
446-
; CHECK-STRONG-SIV-NEXT: da analyze - flow [*|<]!
447-
; CHECK-STRONG-SIV-NEXT: Src: store i32 %conv, ptr %arrayidx, align 4 --> Dst: store i32 %0, ptr %B.addr.02, align 4
448-
; CHECK-STRONG-SIV-NEXT: da analyze - confused!
449-
; CHECK-STRONG-SIV-NEXT: Src: %0 = load i32, ptr %arrayidx2, align 4 --> Dst: %0 = load i32, ptr %arrayidx2, align 4
450-
; CHECK-STRONG-SIV-NEXT: da analyze - none!
451-
; CHECK-STRONG-SIV-NEXT: Src: %0 = load i32, ptr %arrayidx2, align 4 --> Dst: store i32 %0, ptr %B.addr.02, align 4
452-
; CHECK-STRONG-SIV-NEXT: da analyze - confused!
453-
; CHECK-STRONG-SIV-NEXT: Src: store i32 %0, ptr %B.addr.02, align 4 --> Dst: store i32 %0, ptr %B.addr.02, align 4
454-
; CHECK-STRONG-SIV-NEXT: da analyze - none!
426+
; CHECK-LABEL: 'strong9'
427+
; CHECK-NEXT: Src: store i32 %conv, ptr %arrayidx, align 4 --> Dst: store i32 %conv, ptr %arrayidx, align 4
428+
; CHECK-NEXT: da analyze - none!
429+
; CHECK-NEXT: Src: store i32 %conv, ptr %arrayidx, align 4 --> Dst: %0 = load i32, ptr %arrayidx2, align 4
430+
; CHECK-NEXT: da analyze - none!
431+
; CHECK-NEXT: Src: store i32 %conv, ptr %arrayidx, align 4 --> Dst: store i32 %0, ptr %B.addr.02, align 4
432+
; CHECK-NEXT: da analyze - confused!
433+
; CHECK-NEXT: Src: %0 = load i32, ptr %arrayidx2, align 4 --> Dst: %0 = load i32, ptr %arrayidx2, align 4
434+
; CHECK-NEXT: da analyze - none!
435+
; CHECK-NEXT: Src: %0 = load i32, ptr %arrayidx2, align 4 --> Dst: store i32 %0, ptr %B.addr.02, align 4
436+
; CHECK-NEXT: da analyze - confused!
437+
; CHECK-NEXT: Src: store i32 %0, ptr %B.addr.02, align 4 --> Dst: store i32 %0, ptr %B.addr.02, align 4
438+
; CHECK-NEXT: da analyze - none!
455439
;
456440
entry:
457441
%cmp1 = icmp eq i64 %n, 0
@@ -528,45 +512,3 @@ for.body: ; preds = %entry, %for.body
528512
for.end: ; preds = %for.body
529513
ret void
530514
}
531-
532-
533-
;; for (long unsigned i = 0; i < 9223372036854775806; i++)
534-
;; for (long unsigned j = 0; j < 2147483640; j++)
535-
;; if (i < 3000000000)
536-
;; A[i] = 0;
537-
;
538-
; FIXME: DependenceAnalysis fails to detect the dependency between A[i] and
539-
; itself, while Strong SIV has been able to prove it.
540-
define void @strong11(ptr %A) nounwind uwtable ssp {
541-
; CHECK-ALL-LABEL: 'strong11'
542-
; CHECK-ALL-NEXT: Src: store i32 0, ptr %arrayidx, align 4 --> Dst: store i32 0, ptr %arrayidx, align 4
543-
; CHECK-ALL-NEXT: da analyze - none!
544-
;
545-
; CHECK-STRONG-SIV-LABEL: 'strong11'
546-
; CHECK-STRONG-SIV-NEXT: Src: store i32 0, ptr %arrayidx, align 4 --> Dst: store i32 0, ptr %arrayidx, align 4
547-
; CHECK-STRONG-SIV-NEXT: da analyze - consistent output [0 S]!
548-
;
549-
entry:
550-
br label %for.cond1.preheader
551-
552-
for.cond1.preheader: ; preds = %entry, %for.cond.cleanup3
553-
%i.017 = phi i64 [ 0, %entry ], [ %inc8, %for.cond.cleanup3 ]
554-
%cmp5 = icmp samesign ult i64 %i.017, 3000000000
555-
%arrayidx = getelementptr inbounds nuw i32, ptr %A, i64 %i.017
556-
br i1 %cmp5, label %for.body4.us, label %for.cond.cleanup3
557-
558-
for.body4.us: ; preds = %for.cond1.preheader, %for.body4.us
559-
%j.016.us = phi i64 [ %inc.us, %for.body4.us ], [ 0, %for.cond1.preheader ]
560-
store i32 0, ptr %arrayidx, align 4
561-
%inc.us = add nuw nsw i64 %j.016.us, 1
562-
%exitcond.not = icmp eq i64 %inc.us, 2147483640
563-
br i1 %exitcond.not, label %for.cond.cleanup3, label %for.body4.us
564-
565-
for.cond.cleanup: ; preds = %for.cond.cleanup3
566-
ret void
567-
568-
for.cond.cleanup3: ; preds = %for.body4.us, %for.cond1.preheader
569-
%inc8 = add nuw nsw i64 %i.017, 1
570-
%exitcond19.not = icmp eq i64 %inc8, 9223372036854775806
571-
br i1 %exitcond19.not, label %for.cond.cleanup, label %for.cond1.preheader
572-
}

0 commit comments

Comments
 (0)