Skip to content

Commit cd9887e

Browse files
Implement decodeImmediate for VecElementArguments (#36243)
This simply hadn't been wired up yet, which prevented us from being able to use certain intrinsics from the Builtin module (like vector_reduce_smin and friends).
1 parent 5552a4b commit cd9887e

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/AST/Builtins.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,6 @@ Type IntrinsicTypeDecoder::decodeImmediate() {
18641864
case IITDescriptor::HalfVecArgument:
18651865
case IITDescriptor::VarArg:
18661866
case IITDescriptor::Token:
1867-
case IITDescriptor::VecElementArgument:
18681867
case IITDescriptor::VecOfAnyPtrsToElt:
18691868
case IITDescriptor::VecOfBitcastsToInt:
18701869
case IITDescriptor::Subdivide2Argument:
@@ -1892,6 +1891,15 @@ Type IntrinsicTypeDecoder::decodeImmediate() {
18921891
if (!eltType) return Type();
18931892
return makeVector(eltType, D.Vector_Width.getKnownMinValue());
18941893
}
1894+
1895+
// The element type of a vector type.
1896+
case IITDescriptor::VecElementArgument: {
1897+
Type argType = getTypeArgument(D.getArgumentNumber());
1898+
if (!argType) return Type();
1899+
auto vecType = argType->getAs<BuiltinVectorType>();
1900+
if (!vecType) return Type();
1901+
return vecType->getElementType();
1902+
}
18951903

18961904
// A pointer to an immediate type.
18971905
case IITDescriptor::Pointer: {

test/IRGen/builtins.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,17 @@ func cast_test(_ ptr: inout Builtin.RawPointer, i8: inout Builtin.Int8,
158158
d = Builtin.bitcast_Int64_FPIEEE64(i64) // CHECK: bitcast
159159
}
160160

161-
func intrinsic_test(_ i32: inout Builtin.Int32, i16: inout Builtin.Int16) {
161+
func intrinsic_test(_ i32: inout Builtin.Int32, i16: inout Builtin.Int16,
162+
_ v8i16: Builtin.Vec8xInt16) {
163+
// CHECK: intrinsic_test
162164
i32 = Builtin.int_bswap_Int32(i32) // CHECK: llvm.bswap.i32(
163165

164166
i16 = Builtin.int_bswap_Int16(i16) // CHECK: llvm.bswap.i16(
165167

166168
var x = Builtin.int_sadd_with_overflow_Int16(i16, i16) // CHECK: call { i16, i1 } @llvm.sadd.with.overflow.i16(
167169

170+
i16 = Builtin.int_vector_reduce_smin_Vec8xInt16(v8i16) // CHECK: llvm.vector.reduce.smin.v8i16(
171+
168172
Builtin.int_trap() // CHECK: llvm.trap()
169173
}
170174

0 commit comments

Comments
 (0)