summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Vectorize/VPlan.cpp
diff options
context:
space:
mode:
authorAyal Zaks <ayal.zaks@intel.com>2019-08-28 09:02:23 +0000
committerAyal Zaks <ayal.zaks@intel.com>2019-08-28 09:02:23 +0000
commitd15df0ede5898f83a9157fa5985386bd0b17e2c0 (patch)
treebbb25cbe6f4633a053aeb66ca3cc949abbe0dd37 /llvm/lib/Transforms/Vectorize/VPlan.cpp
parent8fbe81fb29e5c7f7d5e68e82063d43410121e6c4 (diff)
downloadbcm5719-llvm-d15df0ede5898f83a9157fa5985386bd0b17e2c0.tar.gz
bcm5719-llvm-d15df0ede5898f83a9157fa5985386bd0b17e2c0.zip
[LV] Fold tail by masking - handle reductions
Allow vectorizing loops that have reductions when tail is folded by masking. A select is introduced in VPlan, choosing between the last value carried by the loop-exit/live-out instruction of the reduction, and the penultimate value carried by the reduction phi, according to the "i < n" mask of fold-tail. This select replaces the last value as the live-out value of the loop. Differential Revision: https://reviews.llvm.org/D66720 llvm-svn: 370173
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/VPlan.cpp')
-rw-r--r--llvm/lib/Transforms/Vectorize/VPlan.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 517d759d7bf..14adb478cd8 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -309,6 +309,14 @@ void VPInstruction::generateInstruction(VPTransformState &State,
State.set(this, V, Part);
break;
}
+ case Instruction::Select: {
+ Value *Cond = State.get(getOperand(0), Part);
+ Value *Op1 = State.get(getOperand(1), Part);
+ Value *Op2 = State.get(getOperand(2), Part);
+ Value *V = Builder.CreateSelect(Cond, Op1, Op2);
+ State.set(this, V, Part);
+ break;
+ }
default:
llvm_unreachable("Unsupported opcode for instruction");
}
OpenPOWER on IntegriCloud