[llvm] [SROA] Support promoting small float array partitions to legal integer types (PR #219125)
Yonah Goldberg via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 26 23:11:59 PDT 2026
https://github.com/YonahGoldberg created https://github.com/llvm/llvm-project/pull/219125
None
>From 7d30578ad34880ce21e38b2d3721411f5901ee40 Mon Sep 17 00:00:00 2001
From: Yonah Goldberg <ygoldberg at nvidia.com>
Date: Thu, 27 Aug 2026 06:10:21 +0000
Subject: [PATCH] [SROA] Prefer legal integers for floating-point arrays
---
llvm/lib/Transforms/Scalar/SROA.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp
index e4770154e2998..4623da0814105 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -5458,11 +5458,12 @@ selectPartitionType(Partition &P, const DataLayout &DL, AllocaInst &AI,
// type?
if (Type *TypePartitionTy = getTypePartition(DL, AI.getAllocatedType(),
P.beginOffset(), P.size())) {
- // If the partition is an integer array that can be spanned by a legal
- // integer type, prefer to represent it as a legal integer type because
- // it's more likely to be promotable.
+ // If the partition is an integer or floating-point array that can be
+ // spanned by a legal integer type, prefer to represent it as a legal
+ // integer type because it's more likely to be promotable.
if (TypePartitionTy->isArrayTy() &&
- TypePartitionTy->getArrayElementType()->isIntegerTy() &&
+ (TypePartitionTy->getArrayElementType()->isIntegerTy() ||
+ TypePartitionTy->getArrayElementType()->isFloatingPointTy()) &&
DL.isLegalInteger(P.size() * 8))
TypePartitionTy = Type::getIntNTy(C, P.size() * 8);
// There was no common type used, so we prefer integer widening promotion.
More information about the llvm-commits
mailing list