https://github.com/MainakSil created 
https://github.com/llvm/llvm-project/pull/108804

Summary:
This PR fixes the issue where the VecLib bitfield in CodeGenOptions.def is too 
small to accommodate the increasing number of vector libraries. Specifically, 
the bitfield size was previously set to 3, but with the introduction of more 
vector libraries (currently 9), the bitfield needed to be expanded to avoid 
potential issues in vectorization.

In this PR, I have increased the size of the VecLib bitfield from 3 to 4 to 
account for the additional libraries. This ensures that all 9 vector libraries 
are correctly encoded and available for use without errors.

Changes Made:
Modified: Increased the VecLib bitfield size from 3 to 4 in 
clang/include/clang/Basic/CodeGenOptions.def.

Motivation:
This change is necessary to ensure that all vector libraries are properly 
represented and selectable. The current limitation of the VecLib bitfield size 
was causing some vectorization opportunities to be lost when more than 3 bits 
were needed to represent the library options.

Closes:
Fixes https://github.com/llvm/llvm-project/issues/108704

>From 43e6c22f25f419b64678374dd247eaf8bc28fa57 Mon Sep 17 00:00:00 2001
From: Mainak Sil <mainaks...@gmail.com>
Date: Mon, 16 Sep 2024 09:50:33 +0530
Subject: [PATCH 1/3] [clang] Increase VecLib bitfield size to 4 bits in
 CodeGenOptions.def

---
 clang/include/clang/Basic/CodeGenOptions.def | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index b600198998d85b..f2a96324936775 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -376,7 +376,7 @@ ENUM_CODEGENOPT(Inlining, InliningMethod, 2, NormalInlining)
 VALUE_CODEGENOPT(InlineMaxStackSize, 32, UINT_MAX)
 
 // Vector functions library to use.
-ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 3, 
llvm::driver::VectorLibrary::NoLibrary)
+ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 4, 
llvm::driver::VectorLibrary::NoLibrary)
 
 /// The default TLS model to use.
 ENUM_CODEGENOPT(DefaultTLSModel, TLSModel, 2, GeneralDynamicTLSModel)

>From b30adc9c059d1af9b5874b5c0e258670d3190852 Mon Sep 17 00:00:00 2001
From: Mainak Sil <mainaks...@gmail.com>
Date: Mon, 16 Sep 2024 14:18:03 +0530
Subject: [PATCH 2/3] Update CodeGenOptions.def

---
 clang/include/clang/Basic/CodeGenOptions.def | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index f2a96324936775..2d5bb84d1cc59c 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -375,6 +375,11 @@ ENUM_CODEGENOPT(Inlining, InliningMethod, 2, 
NormalInlining)
 /// The maximum stack size a function can have to be considered for inlining.
 VALUE_CODEGENOPT(InlineMaxStackSize, 32, UINT_MAX)
 
+// Ensure the VecLib bitfield has enough space for future vector libraries.
+// If new vector libraries are added beyond the current limit of 16, this 
static assertion will fail.
+static_assert(static_cast<int>(llvm::driver::VectorLibrary::NoLibrary) <= 16, 
+              "The VecLib bitfield in CodeGenOptions needs to be expanded to 
support more vector libraries.");
+
 // Vector functions library to use.
 ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 4, 
llvm::driver::VectorLibrary::NoLibrary)
 

>From d96f69105c5be85acf3614258911fbdf74dbc60f Mon Sep 17 00:00:00 2001
From: Mainak Sil <mainaks...@gmail.com>
Date: Mon, 16 Sep 2024 14:32:26 +0530
Subject: [PATCH 3/3] Update CodeGenOptions.def


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to