[polly] r255922 - Fix delinearization of fortran arrays
Roman Gareev via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 17 12:37:18 PST 2015
Author: romangareev
Date: Thu Dec 17 14:37:17 2015
New Revision: 255922
URL: http://llvm.org/viewvc/llvm-project?rev=255922&view=rev
Log:
Fix delinearization of fortran arrays
The patch fixes Bug 25759 produced by inappropriate handling of unsigned
maximum SCEV expressions by SCEVRemoveMax. Without a fix, we get an infinite
loop and a segmentation fault, if we try to process, for example,
'((-1 + (-1 * %b1)) umax {(-1 + (-1 * %yStart)),+,-1}<%.preheader>)'.
It also fixes a potential issue related to signed maximum SCEV expressions.
Tested-by: Roman Gareev <gareevroman at gmail.com>
Fixed-by: Tobias Grosser <tobias at grosser.es>
Differential Revision: http://reviews.llvm.org/D15563
Added:
polly/trunk/test/ScopDetect/scev_remove_max.ll
Modified:
polly/trunk/lib/Analysis/ScopDetection.cpp
Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=255922&r1=255921&r2=255922&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Thu Dec 17 14:37:17 2015
@@ -524,7 +524,7 @@ public:
const SCEV *visitUDivExpr(const SCEVUDivExpr *Expr) { return Expr; }
const SCEV *visitSMaxExpr(const SCEVSMaxExpr *Expr) {
- if (Expr->getOperand(0)->isZero()) {
+ if ((Expr->getNumOperands() == 2) and Expr->getOperand(0)->isZero()) {
auto Res = visit(Expr->getOperand(1));
if (Terms)
(*Terms).push_back(Res);
@@ -534,7 +534,7 @@ public:
return Expr;
}
- const SCEV *visitUMaxExpr(const SCEVUMaxExpr *Expr) { return visit(Expr); }
+ const SCEV *visitUMaxExpr(const SCEVUMaxExpr *Expr) { return Expr; }
const SCEV *visitUnknown(const SCEVUnknown *Expr) { return Expr; }
Added: polly/trunk/test/ScopDetect/scev_remove_max.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopDetect/scev_remove_max.ll?rev=255922&view=auto
==============================================================================
--- polly/trunk/test/ScopDetect/scev_remove_max.ll (added)
+++ polly/trunk/test/ScopDetect/scev_remove_max.ll Thu Dec 17 14:37:17 2015
@@ -0,0 +1,40 @@
+; RUN: opt %loadPolly -polly-detect < %s
+
+; This test case helps to determine wether SCEVRemoveMax::remove produces
+; an infinite loop and a segmentation fault, if it processes, for exmaple,
+; '((-1 + (-1 * %b1)) umax {(-1 + (-1 * %yStart)),+,-1}<%.preheader>)'.
+;
+; In this case, the SCoP is invalid. However, SCoP detection failed when
+; running over it.
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at vertPlane = external global i8*, align 8
+
+define fastcc void @Maze2Mech(i64 %i, i64 %b1, i64 %yStart) {
+.split:
+ br i1 undef, label %DrawSegment.exit, label %DrawSegment.exit34
+
+DrawSegment.exit34: ; preds = %.split
+ %tmp = icmp ugt i64 %yStart, %b1
+ %tmp1 = select i1 %tmp, i64 %b1, i64 %yStart
+ %tmp2 = load i8*, i8** @vertPlane, align 8
+ %y.04.i21 = add i64 %tmp1, 1
+ br label %.lr.ph.i24
+
+.lr.ph.i24: ; preds = %.lr.ph.i24, %DrawSegment.exit34
+ %y.05.i22 = phi i64 [ %y.0.i23, %.lr.ph.i24 ], [ %y.04.i21, %DrawSegment.exit34 ]
+ %tmp3 = mul i64 %y.05.i22, undef
+ %tmp4 = add i64 %tmp3, %i
+ %tmp5 = getelementptr inbounds i8, i8* %tmp2, i64 %tmp4
+ %tmp6 = load i8, i8* %tmp5, align 1
+ %y.0.i23 = add nuw i64 %y.05.i22, 1
+ br i1 false, label %bb, label %.lr.ph.i24
+
+bb: ; preds = %.lr.ph.i24
+ unreachable
+
+DrawSegment.exit: ; preds = %.split
+ ret void
+}
More information about the llvm-commits
mailing list