[PATCH] Refactor identification of reductions and expose them as utility functions

Renato Golin renato.golin at linaro.org
Fri Apr 17 07:54:39 PDT 2015


================
Comment at: include/llvm/Transforms/Utils/LoopUtils.h:67
@@ +66,3 @@
+  // Is this instruction a reduction candidate.
+  bool IsReduction;
+  // The last instruction in a min/max pattern (select of the select(icmp())
----------------
Now that these structs are public, we may want to make them classes to hide these implementation details. Same for ReductionDescriptor.

================
Comment at: include/llvm/Transforms/Utils/LoopUtils.h:139
@@ +138,3 @@
+  /// Returns identity corresponding to the ReductionKind.
+  Constant *getReductionIdentity(ReductionKind K, Type *Tp);
+
----------------
Probably most of these functions can be static. Only the ones operating on the internal memebers should be non-static.

================
Comment at: include/llvm/Transforms/Utils/LoopUtils.h:154
@@ +153,3 @@
+  /// Returns the ReductionKind corresponding to Integer Min/Max operation.
+  ReductionKind getIntMinMax() { return RK_IntegerMinMax; }
+
----------------
I don't think this is necessary, just use ReductionKind::RK_IntegerMinMax or even ReductionKind::IntegerMinMax.

================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:2621
@@ -2793,3 +2620,3 @@
     Value *VectorStart;
-    if (RdxDesc.Kind == LoopVectorizationLegality::RK_IntegerMinMax ||
-        RdxDesc.Kind == LoopVectorizationLegality::RK_FloatMinMax) {
+    if (RdxDesc.Kind == RdxDesc.getIntMinMax() ||
+        RdxDesc.Kind == RdxDesc.getFloatMinMax()) {
----------------
Keep the comparison with the enum value here.

================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:2634
@@ -2806,4 +2633,3 @@
       Constant *Iden =
-      LoopVectorizationLegality::getReductionIdentity(RdxDesc.Kind,
-                                                      VecTy->getScalarType());
+          RdxDesc.getReductionIdentity(RdxDesc.Kind, VecTy->getScalarType());
       if (VF == 1) {
----------------
this should be static function.

http://reviews.llvm.org/D9046

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list