[PATCH] D30211: [LV] Merge floating point and integer induction widening code

Elena Demikhovsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 21 23:46:13 PST 2017


delena added inline comments.


================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:2467
+             : true && "Primary induction variable must have an integer type");
 
   auto II = Legal->getInductionVars()->find(IV);
----------------
I suggest to simplify the expression:
IV->getType()->isIntegerTy() || IV != OldInduction


================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:2501
+  } else {
+    Step = cast<SCEVUnknown>(ID.getStep())->getValue();
+  }
----------------
ID.getStep() should already be SCEVUnknown if it is not scevable.

I think that the following code should work:
  const SCEV *Step = ID.getStep();
  if (PSE.getSE()->isSCEVable(IV->getType())) {
    SCEVExpander Exp(*PSE.getSE(), DL, "induction");
    Step = Exp.expandCodeFor(Step, ID.getStep()->getType(),
                             LoopVectorPreHeader->getTerminator());
   }

And I think you should use IV->getType() instead of ID.getStep()->getType(), while calling to expandCodeFor(), it will expand/truncate if needed.



================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:2635
+  } else {
+    AddOp = Instruction::FAdd;
+    MulOp = Instruction::FMul;
----------------
I'm not 100% sure about the following comment:
For FP, the operation may be FADD or FSUB. It depends on reduction opcode. 


https://reviews.llvm.org/D30211





More information about the llvm-commits mailing list