Call the potentially costly isAnnotatedParallel() only once.
authorPekka Jaaskelainen <pekka.jaaskelainen@tut.fi>
Tue, 23 Apr 2013 16:44:43 +0000 (16:44 +0000)
committerPekka Jaaskelainen <pekka.jaaskelainen@tut.fi>
Tue, 23 Apr 2013 16:44:43 +0000 (16:44 +0000)
Made the uniform write test's checks a bit stricter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180119 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Vectorize/LoopVectorize.cpp
test/Transforms/LoopVectorize/X86/illegal-parallel-loop-uniform-write.ll

index 2e42585e35aeaa297126da14d6775e84529b1919..162587c5659b51aeec7cf5fa60063facad849df1 100644 (file)
@@ -2556,6 +2556,8 @@ bool LoopVectorizationLegality::canVectorizeMemory() {
   PtrRtCheck.Pointers.clear();
   PtrRtCheck.Need = false;
 
+  const bool IsAnnotatedParallel = TheLoop->isAnnotatedParallel();
+
   // For each block.
   for (Loop::block_iterator bb = TheLoop->block_begin(),
        be = TheLoop->block_end(); bb != be; ++bb) {
@@ -2570,7 +2572,7 @@ bool LoopVectorizationLegality::canVectorizeMemory() {
       if (it->mayReadFromMemory()) {
         LoadInst *Ld = dyn_cast<LoadInst>(it);
         if (!Ld) return false;
-        if (!Ld->isSimple() && !TheLoop->isAnnotatedParallel()) {
+        if (!Ld->isSimple() && !IsAnnotatedParallel) {
           DEBUG(dbgs() << "LV: Found a non-simple load.\n");
           return false;
         }
@@ -2582,7 +2584,7 @@ bool LoopVectorizationLegality::canVectorizeMemory() {
       if (it->mayWriteToMemory()) {
         StoreInst *St = dyn_cast<StoreInst>(it);
         if (!St) return false;
-        if (!St->isSimple() && !TheLoop->isAnnotatedParallel()) {
+        if (!St->isSimple() && !IsAnnotatedParallel) {
           DEBUG(dbgs() << "LV: Found a non-simple store.\n");
           return false;
         }
@@ -2629,7 +2631,7 @@ bool LoopVectorizationLegality::canVectorizeMemory() {
       ReadWrites.insert(std::make_pair(Ptr, ST));
   }
 
-  if (TheLoop->isAnnotatedParallel()) {
+  if (IsAnnotatedParallel) {
     DEBUG(dbgs()
           << "LV: A loop annotated parallel, ignore memory dependency "
           << "checks.\n");
index bc606f3ebda8a605641363ac965abed83c203f81..20b0c7421527c9f384d0d62ba924b43df3da87f8 100644 (file)
@@ -4,7 +4,8 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
 target triple = "x86_64-unknown-linux-gnu"
 
 ;CHECK: @foo
-;CHECK-NOT: <4 x 
+;CHECK-NOT: <4 x i32>
+;CHECK: ret void
 
 ; Function Attrs: nounwind uwtable 
 define void @foo(i32* nocapture %a, i32* nocapture %b, i32 %k, i32 %m) #0 {