[llvm] r216656 - Fix: SLPVectorizer tried to move an instruction which was replaced by a vector instruction.
Erik Eckstein
eeckstein at apple.com
Thu Aug 28 00:04:02 PDT 2014
Author: eeckstein
Date: Thu Aug 28 02:04:02 2014
New Revision: 216656
URL: http://llvm.org/viewvc/llvm-project?rev=216656&view=rev
Log:
Fix: SLPVectorizer tried to move an instruction which was replaced by a vector instruction.
For a detailed description of the problem see the comment in the test file.
The problematic moveBefore() calls are not required anymore because the new
scheduling algorithm ensures a correct ordering anyway.
Added:
llvm/trunk/test/Transforms/SLPVectorizer/X86/crash_binaryop.ll
Modified:
llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
Modified: llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp?rev=216656&r1=216655&r2=216656&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp Thu Aug 28 02:04:02 2014
@@ -3112,11 +3112,9 @@ bool SLPVectorizer::tryToVectorize(Binar
BinaryOperator *B0 = dyn_cast<BinaryOperator>(B->getOperand(0));
BinaryOperator *B1 = dyn_cast<BinaryOperator>(B->getOperand(1));
if (tryToVectorizePair(A, B0, R)) {
- B->moveBefore(V);
return true;
}
if (tryToVectorizePair(A, B1, R)) {
- B->moveBefore(V);
return true;
}
}
@@ -3126,11 +3124,9 @@ bool SLPVectorizer::tryToVectorize(Binar
BinaryOperator *A0 = dyn_cast<BinaryOperator>(A->getOperand(0));
BinaryOperator *A1 = dyn_cast<BinaryOperator>(A->getOperand(1));
if (tryToVectorizePair(A0, B, R)) {
- A->moveBefore(V);
return true;
}
if (tryToVectorizePair(A1, B, R)) {
- A->moveBefore(V);
return true;
}
}
Added: llvm/trunk/test/Transforms/SLPVectorizer/X86/crash_binaryop.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SLPVectorizer/X86/crash_binaryop.ll?rev=216656&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/SLPVectorizer/X86/crash_binaryop.ll (added)
+++ llvm/trunk/test/Transforms/SLPVectorizer/X86/crash_binaryop.ll Thu Aug 28 02:04:02 2014
@@ -0,0 +1,41 @@
+; RUN: opt < %s -basicaa -slp-vectorizer -S -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7
+
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-darwin13.3.0"
+
+ at a = common global double 0.000000e+00, align 8
+
+define i32 @fn1() {
+entry:
+ %init = load double* @a, align 8
+ br label %loop
+
+loop:
+ %phi = phi double [ %add2, %loop ], [ %init, %entry ]
+ %postadd1_phi = phi double [ %postadd1, %loop ], [ %init, %entry ]
+ %postadd2_phi = phi double [ %postadd2, %loop ], [ %init, %entry ]
+ %add1 = fadd double %postadd1_phi, undef
+ %add2 = fadd double %postadd2_phi, %phi
+ %mul2 = fmul double %add2, 0.000000e+00
+ %binaryop_B = fadd double %postadd1_phi, %mul2
+ %mul1 = fmul double %add1, 0.000000e+00
+ %tmp = fadd double %postadd2_phi, 0.000000e+00
+
+ ; tryToVectorize() starts with this binary instruction.
+ ; At the same time vectorization wraps around the loop, vectorizes
+ ; postadd1/2 and eventually binary_V and tmp. So binary_V itself is replaced
+ ; with a vector instruction.
+ ; The SLPVectorizer crashed because it tried to use binary_V
+ ; after vectorization to re-arrange instructions.
+ %binary_V = fadd double %mul1, %binaryop_B
+
+ %postadd1 = fadd double %binary_V, 0.000000e+00
+ %postadd2 = fadd double %tmp, 1.000000e+00
+ %tobool = fcmp une double %postadd1, 0.000000e+00
+ br i1 %tobool, label %exit, label %loop
+
+exit:
+ ret i32 1
+}
+
+
More information about the llvm-commits
mailing list