[PATCH] Add support to vectorize ctlz, cttz and powi intrinsics in LoopVectorizer

Arnold Schwaighofer aschwaighofer at apple.com
Thu May 29 13:06:11 PDT 2014


With those changes this LGTM.

Did you run performance tests? Did you see any impact on the test-suite?

Thanks

================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:3084
@@ -3064,1 +3083,3 @@
+        }
+        break;
       default:
----------------
This code is nearly identical to the code in the default statement below. I think this could be refactored into common code?

  default:
        bool HasScalarOpd = hasVectorInstrinsicScalarOpd(ID, 1);
        for (unsigned Part = 0; Part < UF; ++Part) {
          SmallVector<Value *, 4> Args;
          for (unsigned i = 0, ie = CI->getNumArgOperands(); i != ie; ++i) {
            if (HasScalarOpd && i == 1) {
               // pushback scalar.
               continue;
            }
            VectorParts &Arg = getVectorValue(CI->getArgOperand(i));
            Args.push_back(Arg[Part]);
          }
          Type *Tys[] = {CI->getType()};
          if (VF > 1)
            Tys[0] = VectorType::get(CI->getType()->getScalarType(), VF);

          Function *F = Intrinsic::getDeclaration(M, ID, Tys);
          Entry[Part] = Builder.CreateCall(F, Args);
        }
        break;
      }


================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:3438
@@ +3437,3 @@
+      // Intrinsics such as powi,cttz and ctlz are legal to vectorize if the 2nd
+      // argument is same (i.e. loop invariant)
+      if (CI &&
----------------
is the same (i.e. loop invariant).

http://reviews.llvm.org/D3937






More information about the llvm-commits mailing list