[clang] [CIR][AArch64] Add lowering for `svlen` builtins (PR #172346)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 17 09:11:52 PST 2025
Andrzej =?utf-8?q?Warzyński?= <andrzej.warzynski at gmail.com>,
Andrzej =?utf-8?q?Warzyński?= <andrzej.warzynski at gmail.com>,
Andrzej =?utf-8?q?Warzyński?= <andrzej.warzynski at gmail.com>,Andrzej
Warzynski <andrzej.warzynski at arm.com>,Andrzej Warzynski
<andrzej.warzynski at arm.com>,Andrzej Warzynski <andrzej.warzynski at arm.com>,Andrzej
Warzynski <andrzej.warzynski at arm.com>,Andrzej Warzynski
<andrzej.warzynski at arm.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/172346 at github.com>
================
@@ -0,0 +1,170 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 6
+// REQUIRES: aarch64-registered-target
+
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -fclangir -emit-cir -o - %s | FileCheck %s --check-prefixes=ALL,CIR
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -fclangir -emit-cir -o - %s | FileCheck %s --check-prefixes=ALL,CIR
+
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -fclangir -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,LLVM_OGCG_CIR
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -fclangir -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,LLVM_OGCG_CIR
+
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,LLVM_OGCG_CIR
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,LLVM_OGCG_CIR
+
+#include <arm_sve.h>
+
+#if defined __ARM_FEATURE_SME
+#define MODE_ATTR __arm_streaming
+#else
+#define MODE_ATTR
+#endif
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+// ALL-LABEL: @test_svlen_u8
+uint64_t test_svlen_u8(svuint8_t op) MODE_ATTR
+{
+// CIR: %[[VSCALE:.*]] = cir.call_llvm_intrinsic "vscale" : () -> !u64i
+// CIR: %[[C16:.*]] = cir.const #cir.int<16> : !u64i
+// CIR: %[[BINOP:.*]] = cir.binop(mul, %[[VSCALE]], %[[C16]]) nuw : !u64i
+
+// LLVM_OGCG_CIR: [[VSCALE:%.*]] = call i64 @llvm.vscale.i64()
----------------
andykaylor wrote:
Ultimately we do want to align the two paths so that they generate at least semantically equivalent IR, but we're a long way from being able to do that everywhere. Some of the common, but relatively benign, differences are the inclusion of an explicit `__retval` alloca in places where OGCG omits it, and the extra alloca argument. More significant differences arise from the fact that we haven't implemented calling convention handling yet.
We've just been trying to avoid introducing new differences where we can, but we generally accept differences where they are due to missing features or aren't related to the change being made, so what you have here is great.
https://github.com/llvm/llvm-project/pull/172346
More information about the cfe-commits
mailing list