// `indices`. Returns a null Attribute if error happens.
static Attribute extractCompositeElement(Attribute composite,
ArrayRef<unsigned> indices) {
+ // Check that given composite is a constant.
+ if (!composite)
+ return {};
// Return composite itself if we reach the end of the index chain.
if (indices.empty())
return composite;
// -----
+// CHECK-LABEL: extract_from_not_constant
+func @extract_from_not_constant() -> i32 {
+ %0 = spv.Variable : !spv.ptr<vector<3xi32>, Function>
+ %1 = spv.Load "Function" %0 : vector<3xi32>
+ // CHECK: spv.CompositeExtract
+ %2 = spv.CompositeExtract %1[0 : i32] : vector<3xi32>
+ spv.ReturnValue %2 : i32
+}
+
+// -----
+
//===----------------------------------------------------------------------===//
// spv.constant
//===----------------------------------------------------------------------===//