[llvm-branch-commits] [llvm-branch] r260640 - Merging r260587:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Feb 11 17:42:38 PST 2016
Author: hans
Date: Thu Feb 11 19:42:38 2016
New Revision: 260640
URL: http://llvm.org/viewvc/llvm-project?rev=260640&view=rev
Log:
Merging r260587:
------------------------------------------------------------------------
r260587 | pete | 2016-02-11 13:10:40 -0800 (Thu, 11 Feb 2016) | 13 lines
Set load alignment on aggregate loads.
When optimizing a extractvalue(load), we generate a load from the
aggregate type. This load didn't have alignment set and so would
get the alignment of the type. This breaks when the type is packed
and so the alignment should be lower.
For example, loading { int, int } would give us alignment of 4, but
the original load from this type may have an alignment of 1 if packed.
Reviewed by David Majnemer
Differential revision: http://reviews.llvm.org/D17158
------------------------------------------------------------------------
Modified:
llvm/branches/release_38/ (props changed)
llvm/branches/release_38/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/branches/release_38/test/Transforms/InstCombine/unpack-fca.ll
Propchange: llvm/branches/release_38/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 11 19:42:38 2016
@@ -1,3 +1,3 @@
/llvm/branches/Apple/Pertwee:110850,110961
/llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,257645,257648,257730,257775,257791,257875,257886,257902,257905,257925,257929-257930,257940,257942,257977,257979,257997,258168,258184,258207,258221,258273,258325,258406,258416,258428,258436,258471,258690,258729,258891,258971,259177-259178,259228,259236,259342,259346,259375,259381,259645,259649,259695-259696,259740,259798,259835,259840,259886,259888,259958
+/llvm/trunk:155241,257645,257648,257730,257775,257791,257875,257886,257902,257905,257925,257929-257930,257940,257942,257977,257979,257997,258168,258184,258207,258221,258273,258325,258406,258416,258428,258436,258471,258690,258729,258891,258971,259177-259178,259228,259236,259342,259346,259375,259381,259645,259649,259695-259696,259740,259798,259835,259840,259886,259888,259958,260587
Modified: llvm/branches/release_38/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp?rev=260640&r1=260639&r2=260640&view=diff
==============================================================================
--- llvm/branches/release_38/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp (original)
+++ llvm/branches/release_38/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp Thu Feb 11 19:42:38 2016
@@ -557,7 +557,8 @@ static Instruction *unpackLoadToAggregat
ConstantInt::get(IdxType, i),
};
auto *Ptr = IC.Builder->CreateInBoundsGEP(ST, Addr, makeArrayRef(Indices), EltName);
- auto *L = IC.Builder->CreateLoad(ST->getTypeAtIndex(i), Ptr, LoadName);
+ auto *L = IC.Builder->CreateAlignedLoad(Ptr, LI.getAlignment(),
+ LoadName);
V = IC.Builder->CreateInsertValue(V, L, i);
}
Modified: llvm/branches/release_38/test/Transforms/InstCombine/unpack-fca.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/test/Transforms/InstCombine/unpack-fca.ll?rev=260640&r1=260639&r2=260640&view=diff
==============================================================================
--- llvm/branches/release_38/test/Transforms/InstCombine/unpack-fca.ll (original)
+++ llvm/branches/release_38/test/Transforms/InstCombine/unpack-fca.ll Thu Feb 11 19:42:38 2016
@@ -136,3 +136,18 @@ define %B @structB(%B* %b.ptr) {
%1 = load %B, %B* %b.ptr, align 8
ret %B %1
}
+
+%struct.S = type <{ i8, %struct.T }>
+%struct.T = type { i32, i32 }
+
+; Make sure that we do not increase alignment of packed struct element
+define i32 @packed_alignment(%struct.S* dereferenceable(9) %s) {
+; CHECK-LABEL: packed_alignment
+; CHECK-NEXT: %tv.elt1 = getelementptr inbounds %struct.S, %struct.S* %s, i64 0, i32 1, i32 1
+; CHECK-NEXT: %tv.unpack2 = load i32, i32* %tv.elt1, align 1
+; CHECK-NEXT: ret i32 %tv.unpack2
+ %t = getelementptr inbounds %struct.S, %struct.S* %s, i32 0, i32 1
+ %tv = load %struct.T, %struct.T* %t, align 1
+ %v = extractvalue %struct.T %tv, 1
+ ret i32 %v
+}
More information about the llvm-branch-commits
mailing list