Right now the alignment of the lower half of a store is computed as
align/2, which fails for unaligned stores (align = 1), and is overly
pessimitic for, e.g. a 8 byte store aligned to 4 bytes.
Fixes PR44851
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/CodeGen/CodeGenPrepare.cpp | ||
---|---|---|
6873 | Can you reuse Alignment here? |
llvm/lib/CodeGen/CodeGenPrepare.cpp | ||
---|---|---|
6874 | On a first read, this is very confusing. | |
6876 | Can the no-longer-pessimism of the computation be demonstrated by the tests? |
llvm/test/CodeGen/X86/split-store-unaligned.ll | ||
---|---|---|
30 ↗ | (On Diff #243529) | Hmm. |
LG to me.
llvm/test/CodeGen/PowerPC/split-store-alignment.ll | ||
---|---|---|
2–3 ↗ | (On Diff #243549) | Please unique checklines ; RUN: opt -S -mtriple=powerpc64le -codegenprepare -force-split-store < %s | FileCheck --check-prefixes=ALL,PPC64LE %s ; RUN: opt -S -mtriple=powerpc64 -codegenprepare -force-split-store < %s | FileCheck --check-prefixes=ALL,PPC64 %s |
101–102 ↗ | (On Diff #243549) | Okay, i guess there is no big-endian issue after all. |
llvm/test/CodeGen/PowerPC/split-store-alignment.ll | ||
---|---|---|
101–102 ↗ | (On Diff #243549) | Wait - why is there no difference between LE and BE here? |
CGP is not creating an appropriate default datalayout based on triple, so we need to specify it explicitly:
$ opt -S splitstore.ll -mtriple=powerpc64 -data-layout="E" -force-split-store -codegenprepare ; ModuleID = 'splitstore.ll' source_filename = "splitstore.ll" target datalayout = "E" target triple = "powerpc64" define void @split_store_align8(i32 %x, i64* %p) { %z = zext i32 43 to i64 %s = shl nuw nsw i64 %z, 32 %z2 = zext i32 %x to i64 %o = or i64 %s, %z2 %1 = bitcast i64* %p to i32* %2 = getelementptr i32, i32* %1, i32 1 store i32 %x, i32* %2, align 8 %3 = bitcast i64* %p to i32* store i32 43, i32* %3, align 4 ret void }
$ opt -S splitstore.ll -mtriple=powerpc64le -data-layout="e" -force-split-store -codegenprepare ; ModuleID = 'splitstore.ll' source_filename = "splitstore.ll" target datalayout = "e" target triple = "powerpc64le" define void @split_store_align8(i32 %x, i64* %p) { %z = zext i32 43 to i64 %s = shl nuw nsw i64 %z, 32 %z2 = zext i32 %x to i64 %o = or i64 %s, %z2 %1 = bitcast i64* %p to i32* store i32 %x, i32* %1, align 8 %2 = bitcast i64* %p to i32* %3 = getelementptr i32, i32* %2, i32 1 store i32 43, i32* %3, align 4 ret void }
Add target triple in module in tests, which shows the brokenness of alignment
for BE targets. Fit it.
CGP is not creating an appropriate default datalayout based on triple, so we need to specify it explicitly:
Thanks !
LG for real now :)
llvm/test/CodeGen/PowerPC/split-store-alignment.ll | ||
---|---|---|
101–102 ↗ | (On Diff #243549) | Oops, thanks for catching that. |
LGTM - see inline for a comment nit and some potential test changes.
llvm/lib/CodeGen/CodeGenPrepare.cpp | ||
---|---|---|
6874 | The suggested "one half" is better than the current "lower half" - eliminate the endian-specific inaccuracy. | |
llvm/test/CodeGen/PowerPC/split-store-alignment-le.ll | ||
2 ↗ | (On Diff #243750) | Unless I'm missing some advantage of the way of the tests are arranged currently, I prefer that:
|
We probably want to backport the big-endian fix into 10.0 in some form?
Please do file a bug
Can you reuse Alignment here?