This patch merges the existing floating point induction variable widening code into the integer induction variable widening code, creating a single set of functions for both kinds of inductions. The primary motivation for doing this is to enable vector phi node creation for floating point induction variables.
Details
Diff Detail
- Build Status
Buildable 4186 Build 4186: arc lint + arc unit
Event Timeline
Thanks, this basically looks good, a few comments inline.
lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
387 | Nothing changed here, you just moved it around, right? | |
400 | One of the users of this for the int case was a getSigned(), and now it's a get(). Are you sure this is correct? | |
test/Transforms/LoopVectorize/float-induction.ll | ||
4 | Did you run it through the update script? If you did, could you have the diff show the actual diff vs. running it with the old code? |
lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
2468 | I suggest to simplify the expression: | |
2502 | 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. | |
2637 | I'm not 100% sure about the following comment: |
lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
2502 | Step needs to be a Value, not a SCEV, hence the else. As to the other change - I think this patch is trying to be NFC for ints, so I think I'd prefer we not change that in this patch. | |
2637 | I think you're right. (You mean induction opcode, right?) |
lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
387 | Right, I just moved it so I could reuse it. | |
400 | You're right, nice catch! | |
2468 | Yes that's much simpler. Thanks! | |
2637 | Ah, yes that's true. We'll need to get the step BinOp from the induction descriptor. Thanks! | |
test/Transforms/LoopVectorize/float-induction.ll | ||
4 | Hey Michael, can you clarify what you mean here? I did use the script to help generate the checks (then moved the test into this file). You're just wanting to see the lines that are different with and without the patch? |
test/Transforms/LoopVectorize/float-induction.ll | ||
---|---|---|
4 | Yes, otherwise it's kind of hard to see what changed. |
test/Transforms/LoopVectorize/float-induction.ll | ||
---|---|---|
4 | Great, that's what I was thinking as well. |
Addressed comments from Michael and Elena. Thanks!
- Changed the constant helper to use signed values.
- Simplified assert in widenIntOrFpInduction.
- Used the induction opcode from the induction descriptor for the "AddOp" in buildScalarSteps and createVectorIntOrFPInductionPHI. I corrected one of the test cases I incorrectly updated the first time around. It now correctly uses fsub instead of fadd for the induction update.
- Rebased new test case.
lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
400 | Both of the original uses (get and getSigned) could only ever have values greater than one (and much less than the max int64_t) so I don't think it makes a difference either way. If we go with a helper function here, I think the signed version is less confusing. | |
test/Transforms/LoopVectorize/float-induction.ll | ||
4 | Ah, I see! Sorry for the confusion. I'll run the script over the tests I changed and rebase. |
lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
400 | Yeah, makes sense. |
lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
4741 | Is the pointer induction really different from int and FP induction? |
lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
4741 | It's not, and I'm planning to work on this soon. Thanks! |
lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
4741 | I'd put them all in one patch and call the function widenInduction(). but it is not a stumbling-block anyway. |
lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
4741 | Would you mind if we did this in a separate patch? I was trying to focus this one on floating-point, while keeping everything thing else as NFC as possible. Once committed, we can make sure no performance issues crop up for anyone before moving on to the pointer induction variables. The suggestion makes sense - I just would like to keep things small for review and codgen investigations should the need arise. |
lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
4741 | Hi Elena, I'm going to go ahead and commit this - assuming no issues arise over the weekend, I'll submit a patch to take care of the pointer inductions early next week, like you suggested. |
Nothing changed here, you just moved it around, right?