summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorWhitney Tsang <whitney.uwaterloo@gmail.com>2019-06-06 15:12:49 +0000
committerWhitney Tsang <whitney.uwaterloo@gmail.com>2019-06-06 15:12:49 +0000
commit03e8369a72804d2aeebb2dc36ee17f32c7537275 (patch)
treed3470341c9959992fdc9ffe65dff5d907bcbf4d5 /llvm/lib
parent0924f4485921f2e833ffb4f7f6fd203608044fce (diff)
downloadbcm5719-llvm-03e8369a72804d2aeebb2dc36ee17f32c7537275.tar.gz
bcm5719-llvm-03e8369a72804d2aeebb2dc36ee17f32c7537275.zip
[DA] Add an option to control delinearization validity checks
Summary: Dependence Analysis performs static checks to confirm validity of delinearization. These checks often fail for 64-bit targets due to type conversions and integer wrapping that prevent simplification of the SCEV expressions. These checks would also fail at compile-time if the lower bound of the loops are compile-time unknown. For example: void foo(int n, int m, int a[][m]) { for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) { a[i][j] = a[i+1][j-2]; } } opt -mem2reg -instcombine -indvars -loop-simplify -loop-rotate -inline -pass-remarks=.* -debug-pass=Arguments -da-permissive-validity-checks=false k3.ll -analyze -da will produce the following by default: da analyze - anti [* *|<]! but will produce the following expected dependence vector if the validity checks are disabled: da analyze - consistent anti [1 -2]! This revision will introduce a debug option that will leave the validity checks in place by default, but allow them to be turned off. New tests are added for cases where it cannot be proven at compile-time that the individual subscripts stay in-bound with respect to a particular dimension of an array. These tests enable the option to provide user guarantee that the subscripts do not over/under-flow into other dimensions, thereby producing more accurate dependence vectors. For prior discussion on this topic, leading to this change, please see the following thread: http://lists.llvm.org/pipermail/llvm-dev/2019-May/132372.html Reviewers: Meinersbur, jdoerfert, kbarton, dmgreen, fhahn Reviewed By: Meinersbur, jdoerfert, dmgreen Subscribers: fhahn, hiraditya, javed.absar, llvm-commits, Whitney, etiotto Tag: LLVM Differential Revision: https://reviews.llvm.org/D62610 llvm-svn: 362711
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/DependenceAnalysis.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index 8337b9b96ea..75f269e84f9 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -109,6 +109,14 @@ STATISTIC(BanerjeeSuccesses, "Banerjee successes");
static cl::opt<bool>
Delinearize("da-delinearize", cl::init(true), cl::Hidden, cl::ZeroOrMore,
cl::desc("Try to delinearize array references."));
+static cl::opt<bool> DisableDelinearizationChecks(
+ "da-disable-delinearization-checks", cl::init(false), cl::Hidden,
+ cl::ZeroOrMore,
+ cl::desc(
+ "Disable checks that try to statically verify validity of "
+ "delinearized subscripts. Enabling this option may result in incorrect "
+ "dependence vectors for languages that allow the subscript of one "
+ "dimension to underflow or overflow into another dimension."));
//===----------------------------------------------------------------------===//
// basics
@@ -3316,19 +3324,20 @@ bool DependenceInfo::tryDelinearize(Instruction *Src, Instruction *Dst,
// and dst.
// FIXME: It may be better to record these sizes and add them as constraints
// to the dependency checks.
- for (int i = 1; i < size; ++i) {
- if (!isKnownNonNegative(SrcSubscripts[i], SrcPtr))
- return false;
+ if (!DisableDelinearizationChecks)
+ for (int i = 1; i < size; ++i) {
+ if (!isKnownNonNegative(SrcSubscripts[i], SrcPtr))
+ return false;
- if (!isKnownLessThan(SrcSubscripts[i], Sizes[i - 1]))
- return false;
+ if (!isKnownLessThan(SrcSubscripts[i], Sizes[i - 1]))
+ return false;
- if (!isKnownNonNegative(DstSubscripts[i], DstPtr))
- return false;
+ if (!isKnownNonNegative(DstSubscripts[i], DstPtr))
+ return false;
- if (!isKnownLessThan(DstSubscripts[i], Sizes[i - 1]))
- return false;
- }
+ if (!isKnownLessThan(DstSubscripts[i], Sizes[i - 1]))
+ return false;
+ }
LLVM_DEBUG({
dbgs() << "\nSrcSubscripts: ";
OpenPOWER on IntegriCloud