[PATCH] D30259: GlobalISel: Translate ConstantAggregateZero vectors
Volkan Keles via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 22 09:00:34 PST 2017
volkan created this revision.
Herald added subscribers: kristof.beyls, rovka, dberris.
Herald added a reviewer: javed.absar.
https://reviews.llvm.org/D30259
Files:
lib/CodeGen/GlobalISel/IRTranslator.cpp
test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
Index: test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
===================================================================
--- test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
+++ test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
@@ -1189,3 +1189,12 @@
ret void
}
+
+define <2 x i32> @test_constant_agg_zero_vector() {
+; CHECK-LABEL: name: test_constant_agg_zero_vector
+; CHECK: [[ZERO:%[0-9]+]](s32) = G_CONSTANT i32 0
+; CHECK: [[RES:%[0-9]+]](<2 x s32>) = G_SEQUENCE [[ZERO]](s32), 0, [[ZERO]](s32), 32
+; CHECK: %d0 = COPY [[RES]](<2 x s32>)
+entry:
+ ret <2 x i32> zeroinitializer
+}
Index: lib/CodeGen/GlobalISel/IRTranslator.cpp
===================================================================
--- lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -979,7 +979,21 @@
EntryBuilder.buildConstant(Reg, 0);
else if (auto GV = dyn_cast<GlobalValue>(&C))
EntryBuilder.buildGlobalValue(Reg, GV);
- else if (auto CE = dyn_cast<ConstantExpr>(&C)) {
+ else if (auto CAZ = dyn_cast<ConstantAggregateZero>(&C)) {
+ if (!CAZ->getType()->isVectorTy()) {
+ if (!TPC->isGlobalISelAbortEnabled())
+ return false;
+ llvm_unreachable("unhandled constant aggregate zero");
+ }
+ std::vector<unsigned> Ops;
+ std::vector<uint64_t> Indices;
+ for (unsigned i = 0; i < CAZ->getNumElements(); ++i) {
+ Constant &Elt = *CAZ->getElementValue(i);
+ Ops.push_back(getOrCreateVReg(Elt));
+ Indices.push_back(i * CAZ->getType()->getScalarSizeInBits());
+ }
+ EntryBuilder.buildSequence(Reg, Ops, Indices);
+ } else if (auto CE = dyn_cast<ConstantExpr>(&C)) {
switch(CE->getOpcode()) {
#define HANDLE_INST(NUM, OPCODE, CLASS) \
case Instruction::OPCODE: return translate##OPCODE(*CE, EntryBuilder);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30259.89370.patch
Type: text/x-patch
Size: 1843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170222/db6b2ba7/attachment.bin>
More information about the llvm-commits
mailing list