Skip to content

Commit 62744f3

Browse files
authored
[AArch64][NEON] NEON intrinsic compilation error with -fno-lax-vector-conversion flag fix (#149329)
Issue originally raised in #71362 (comment). Certain NEON intrinsics that operate on poly types (e.g. poly8x8_t) failed to compile with the -fno-lax-vector-conversions flag. This patch updates NeonEmitter.cpp to insert an explicit __builtin_bit_cast from poly types to the required signed integer vector types when generating lane-related intrinsics. A test 'neon-bitcast-poly.ll' is included.
1 parent 2ec91a5 commit 62744f3

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

clang/test/CodeGen/AArch64/neon-scalar-copy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
1+
// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -flax-vector-conversions=none\
22
// RUN: -disable-O0-optnone -emit-llvm -o - %s | opt -S -passes=mem2reg | FileCheck %s
33

44
// REQUIRES: aarch64-registered-target || arm-registered-target

clang/test/CodeGen/AArch64/neon-vget.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple arm64-apple-darwin -target-feature +neon \
1+
// RUN: %clang_cc1 -triple arm64-apple-darwin -target-feature +neon -flax-vector-conversions=none \
22
// RUN: -disable-O0-optnone -emit-llvm -o - %s \
33
// RUN: | opt -S -passes=mem2reg | FileCheck %s
44

clang/test/CodeGen/AArch64/poly64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
2-
// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
2+
// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -flax-vector-conversions=none\
33
// RUN: -ffp-contract=fast -disable-O0-optnone -emit-llvm -o - %s | opt -S -passes=mem2reg,sroa \
44
// RUN: | FileCheck %s
55

clang/utils/TableGen/NeonEmitter.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,14 +1401,12 @@ void Intrinsic::emitBodyAsBuiltinCall() {
14011401
if (LocalCK == ClassB || (T.isHalf() && !T.isScalarForMangling())) {
14021402
CastToType.makeInteger(8, true);
14031403
Arg = "__builtin_bit_cast(" + CastToType.str() + ", " + Arg + ")";
1404-
} else if (LocalCK == ClassI) {
1405-
if (CastToType.isInteger()) {
1406-
CastToType.makeSigned();
1407-
Arg = "__builtin_bit_cast(" + CastToType.str() + ", " + Arg + ")";
1408-
}
1404+
} else if (LocalCK == ClassI &&
1405+
(CastToType.isInteger() || CastToType.isPoly())) {
1406+
CastToType.makeSigned();
1407+
Arg = "__builtin_bit_cast(" + CastToType.str() + ", " + Arg + ")";
14091408
}
14101409
}
1411-
14121410
S += Arg + ", ";
14131411
}
14141412

0 commit comments

Comments
 (0)