summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/2009-03-02-VarLengthArrayGEP.ll
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2009-03-02 09:18:21 +0000
committerDuncan Sands <baldrick@free.fr>2009-03-02 09:18:21 +0000
commit5795a6091df9cd110824f4bc89ebda78bebfbe8a (patch)
tree24bedc1bb7782fad211b2cc64e3ff95760895d8c /llvm/test/Transforms/InstCombine/2009-03-02-VarLengthArrayGEP.ll
parent7cff81825ffde01c2085cebca463fd837c0b4775 (diff)
downloadbcm5719-llvm-5795a6091df9cd110824f4bc89ebda78bebfbe8a.tar.gz
bcm5719-llvm-5795a6091df9cd110824f4bc89ebda78bebfbe8a.zip
Fix PR3694: add an instcombine micro-optimization that helps
clean up when using variable length arrays in llvm-gcc. llvm-svn: 65832
Diffstat (limited to 'llvm/test/Transforms/InstCombine/2009-03-02-VarLengthArrayGEP.ll')
-rw-r--r--llvm/test/Transforms/InstCombine/2009-03-02-VarLengthArrayGEP.ll14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/2009-03-02-VarLengthArrayGEP.ll b/llvm/test/Transforms/InstCombine/2009-03-02-VarLengthArrayGEP.ll
new file mode 100644
index 00000000000..1e136f5eab3
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/2009-03-02-VarLengthArrayGEP.ll
@@ -0,0 +1,14 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {getelementptr i32}
+; PR3694
+
+define i32 @e(i32 %m, i32 %n) nounwind {
+entry:
+ %0 = alloca i32, i32 %n, align 4 ; <i32*> [#uses=2]
+ %1 = bitcast i32* %0 to [0 x i32]* ; <[0 x i32]*> [#uses=1]
+ call void @f(i32* %0) nounwind
+ %2 = getelementptr [0 x i32]* %1, i32 0, i32 %m ; <i32*> [#uses=1]
+ %3 = load i32* %2, align 4 ; <i32> [#uses=1]
+ ret i32 %3
+}
+
+declare void @f(i32*)
OpenPOWER on IntegriCloud