[PATCH] Add support for one element array store in InstCombine
David Majnemer
david.majnemer at gmail.com
Sun May 10 22:08:05 PDT 2015
REPOSITORY
rL LLVM
http://reviews.llvm.org/D9591
Files:
llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/trunk/test/Transforms/InstCombine/unpack-fca.ll
Index: llvm/trunk/test/Transforms/InstCombine/unpack-fca.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/unpack-fca.ll
+++ llvm/trunk/test/Transforms/InstCombine/unpack-fca.ll
@@ -32,6 +32,26 @@
ret void
}
+define void @storeArrayOfA() {
+body:
+ %0 = tail call i8* @allocmemory(i64 32)
+ %1 = bitcast i8* %0 to [1 x %A]*
+; CHECK-LABEL: storeStructOfA
+; CHECK: store %A__vtbl* @A__vtblZ
+ store [1 x %A] [%A { %A__vtbl* @A__vtblZ }], [1 x %A]* %1, align 8
+ ret void
+}
+
+define void @storeStructOfArrayOfA() {
+body:
+ %0 = tail call i8* @allocmemory(i64 32)
+ %1 = bitcast i8* %0 to { [1 x %A] }*
+; CHECK-LABEL: storeStructOfArrayOfA
+; CHECK: store %A__vtbl* @A__vtblZ
+ store { [1 x %A] } { [1 x %A] [%A { %A__vtbl* @A__vtblZ }] }, { [1 x %A] }* %1, align 8
+ ret void
+}
+
define %A @loadA() {
body:
%0 = tail call i8* @allocmemory(i64 32)
Index: llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -880,6 +880,15 @@
}
}
+ if (auto *AT = dyn_cast<ArrayType>(T)) {
+ // If the array only have one element, we unpack.
+ if (AT->getNumElements() == 1) {
+ V = IC.Builder->CreateExtractValue(V, 0);
+ combineStoreToNewValue(IC, SI, V);
+ return true;
+ }
+ }
+
return false;
}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9591.25442.patch
Type: text/x-patch
Size: 1543 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150511/6b9e2f2f/attachment.bin>
More information about the llvm-commits
mailing list