Skip to content

Commit 03c4dd9

Browse files
committed
prefer integer partitions
1 parent cf9cb54 commit 03c4dd9

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

llvm/lib/Transforms/Scalar/SROA.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5234,7 +5234,9 @@ AllocaInst *SROA::rewritePartition(AllocaInst &AI, AllocaSlices &AS,
52345234
SliceTy = TypePartitionTy;
52355235

52365236
// If still not, can we use the largest bitwidth integer type used?
5237-
if (!SliceTy && CommonUseTy.second)
5237+
// If SliceTy is a non-promotable aggregate, prefer to represent as an integer type
5238+
// because it's more likely to be promotable.
5239+
if ((!SliceTy || !SliceTy->isSingleValueType()) && CommonUseTy.second)
52385240
if (DL.getTypeAllocSize(CommonUseTy.second).getFixedValue() >= P.size()) {
52395241
SliceTy = CommonUseTy.second;
52405242
SliceVecTy = dyn_cast<VectorType>(SliceTy);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt < %s -passes=sroa -S | FileCheck %s
3+
4+
; Ensure that the [2 x half] alloca is spanned by an i32 partition.
5+
6+
define void @test() {
7+
; CHECK-LABEL: @test(
8+
; CHECK-NEXT: entry:
9+
; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32 42 to float
10+
; CHECK-NEXT: ret void
11+
;
12+
entry:
13+
%alloca = alloca [2 x half]
14+
store i32 42, ptr %alloca
15+
%val = load float, ptr %alloca
16+
ret void
17+
}

0 commit comments

Comments
 (0)