[llvm-commits] [llvm] r171023 - in /llvm/trunk: lib/Transforms/Vectorize/LoopVectorize.cpp test/Transforms/LoopVectorize/X86/struct-store.ll

Nadav Rotem nrotem at apple.com
Mon Dec 24 01:14:18 PST 2012


Author: nadav
Date: Mon Dec 24 03:14:18 2012
New Revision: 171023

URL: http://llvm.org/viewvc/llvm-project?rev=171023&view=rev
Log:
LoopVectorizer: When checking for vectorizable types, also check
the StoreInst operands.

PR14705.


Added:
    llvm/trunk/test/Transforms/LoopVectorize/X86/struct-store.ll
Modified:
    llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp

Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=171023&r1=171022&r2=171023&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Mon Dec 24 03:14:18 2012
@@ -1464,13 +1464,20 @@
         return false;
       }
 
-      // We do not re-vectorize vectors.
+      // Check that the instruction return type is vectorizable.
       if (!VectorType::isValidElementType(it->getType()) &&
           !it->getType()->isVoidTy()) {
         DEBUG(dbgs() << "LV: Found unvectorizable type." << "\n");
         return false;
       }
 
+      // Check that the stored type is vectorizable.
+      if (StoreInst *ST = dyn_cast<StoreInst>(it)) {
+        Type *T = ST->getValueOperand()->getType();
+        if (!VectorType::isValidElementType(T))
+          return false;
+      }
+
       // Reduction instructions are allowed to have exit users.
       // All other instructions must not have external users.
       if (!AllowedExit.count(it))

Added: llvm/trunk/test/Transforms/LoopVectorize/X86/struct-store.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopVectorize/X86/struct-store.ll?rev=171023&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/LoopVectorize/X86/struct-store.ll (added)
+++ llvm/trunk/test/Transforms/LoopVectorize/X86/struct-store.ll Mon Dec 24 03:14:18 2012
@@ -0,0 +1,29 @@
+; RUN: opt < %s  -loop-vectorize -mtriple=x86_64-unknown-linux-gnu -S
+
+; Makre sure we are not crashing on this one.
+
+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"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at glbl = external global [16 x { i64, i64 }], align 16
+
+declare void @fn()
+
+define void @test() {
+entry:
+  br label %loop
+
+loop:
+  %indvars.iv = phi i64 [ %indvars.iv.next, %loop ], [ 0, %entry ]
+  %tmp = getelementptr inbounds [16 x { i64, i64 }]* @glbl, i64 0, i64
+%indvars.iv
+  store { i64, i64 } { i64 ptrtoint (void ()* @fn to i64), i64 0 }, { i64, i64 }* %tmp, align 16
+  %indvars.iv.next = add i64 %indvars.iv, 1
+  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
+  %exitcond = icmp ne i32 %lftr.wideiv, 16
+  br i1 %exitcond, label %loop, label %exit
+
+exit:
+  ret void
+}





More information about the llvm-commits mailing list