// must match the dest vector size.
LLT DstTy = MRI->getType(MI->getOperand(0).getReg());
LLT SrcEltTy = MRI->getType(MI->getOperand(1).getReg());
- if (!DstTy.isVector() || SrcEltTy.isVector())
+ if (!DstTy.isVector() || SrcEltTy.isVector()) {
report("G_BUILD_VECTOR must produce a vector from scalar operands", MI);
+ break;
+ }
+
+ if (DstTy.getElementType() != SrcEltTy)
+ report("G_BUILD_VECTOR result element type must match source type", MI);
+
+ if (DstTy.getNumElements() != MI->getNumOperands() - 1)
+ report("G_BUILD_VECTOR must have an operand for each elemement", MI);
+
for (unsigned i = 2; i < MI->getNumOperands(); ++i) {
if (MRI->getType(MI->getOperand(1).getReg()) !=
MRI->getType(MI->getOperand(i).getReg()))
report("G_BUILD_VECTOR source operand types are not homogeneous", MI);
}
- if (DstTy.getSizeInBits() !=
- SrcEltTy.getSizeInBits() * (MI->getNumOperands() - 1))
- report("G_BUILD_VECTOR src operands total size don't match dest "
- "size.",
- MI);
+
break;
}
case TargetOpcode::G_BUILD_VECTOR_TRUNC: {
-#RUN: not llc -o - -global-isel -run-pass=none -verify-machineinstrs %s 2>&1 | FileCheck %s
+# RUN: not llc -o - -global-isel -run-pass=none -verify-machineinstrs %s 2>&1 | FileCheck %s
# REQUIRES: aarch64-registered-target
---- |
- target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
- target triple = "aarch64-unknown-unknown"
-
- define i32 @g_build_vector() {
- ret i32 0
- }
-
-...
---
name: g_build_vector
-legalized: true
-regBankSelected: false
-selected: false
tracksRegLiveness: true
-registers:
- - { id: 0, class: _, preferred-register: '' }
liveins:
body: |
bb.0:
- ; CHECK: Bad machine code: G_BUILD_VECTOR src operands total size don't match dest size
+ %0:_(s32) = IMPLICIT_DEF
+
+ ; CHECK: Bad machine code: G_BUILD_VECTOR must produce a vector from scalar operands
+ %1:_(s32) = G_BUILD_VECTOR %0
+
+ %2:_(<2 x s32>) = IMPLICIT_DEF
+
+ ; CHECK: Bad machine code: G_BUILD_VECTOR must produce a vector from scalar operands
+ %3:_(<2 x s32>) = G_BUILD_VECTOR %2
+
+ ; CHECK: Bad machine code: G_BUILD_VECTOR must have an operand for each elemement
+ %4:_(<2 x s32>) = G_BUILD_VECTOR %0, %0, %0, %0
+
+ ; CHECK: Bad machine code: G_BUILD_VECTOR result element type must match source type
+ ; CHECK: Bad machine code: G_BUILD_VECTOR must have an operand for each elemement
+ %5:_(<4 x s16>) = G_BUILD_VECTOR %0, %0
+
+ %6:_(s16) = IMPLICIT_DEF
+
+ ; CHECK: Bad machine code: G_BUILD_VECTOR result element type must match source type
+ ; CHECK: Bad machine code: G_BUILD_VECTOR must have an operand for each elemement
+ %7:_(<2 x s32>) = G_BUILD_VECTOR %6, %6, %6, %6
+
+ %8:_(p0) = IMPLICIT_DEF
+
+ ; CHECK: Bad machine code: G_BUILD_VECTOR result element type must match source type
+ %9:_(<2 x s64>) = G_BUILD_VECTOR %8, %8
+
+ %10:_(s64) = IMPLICIT_DEF
- %0(s32) = IMPLICIT_DEF
- %1:_(<2 x s32>) = G_BUILD_VECTOR %0, %0, %0, %0
+ ; CHECK: Bad machine code: G_BUILD_VECTOR result element type must match source type
+ %11:_(<2 x p0>) = G_BUILD_VECTOR %10, %10
...