summaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine
diff options
context:
space:
mode:
authorNadav Rotem <nadav.rotem@intel.com>2011-04-05 14:29:52 +0000
committerNadav Rotem <nadav.rotem@intel.com>2011-04-05 14:29:52 +0000
commit0286ca89f0734a81c273e80732a573f619c7ace4 (patch)
treec664441ac594a8c2bf50a1b207a4933d08e33762 /test/Transforms/InstCombine
parent45c435a24a048c53714c2ebda74037befaf8725c (diff)
downloadllvm-0286ca89f0734a81c273e80732a573f619c7ace4.tar.gz
llvm-0286ca89f0734a81c273e80732a573f619c7ace4.tar.bz2
llvm-0286ca89f0734a81c273e80732a573f619c7ace4.tar.xz
InstCombine optimizes gep(bitcast(x)) even when the bitcasts casts away address
space info. We crash with an assert in this case. This change checks that the address space of the bitcasted pointer is the same as the gep ptr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128884 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine')
-rw-r--r--test/Transforms/InstCombine/gep-addrspace.ll16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/gep-addrspace.ll b/test/Transforms/InstCombine/gep-addrspace.ll
new file mode 100644
index 0000000000..4c971072cf
--- /dev/null
+++ b/test/Transforms/InstCombine/gep-addrspace.ll
@@ -0,0 +1,16 @@
+; RUN: opt < %s -instcombine -S
+
+%myStruct = type { float, [3 x float], [4 x float], i32 }
+
+; make sure that we are not crashing when creating an illegal type
+define void @func(%myStruct addrspace(1)* nocapture %p) nounwind {
+ST:
+ %A = getelementptr inbounds %myStruct addrspace(1)* %p, i64 0
+ %B = bitcast %myStruct addrspace(1)* %A to %myStruct*
+ %C = getelementptr inbounds %myStruct* %B, i32 0, i32 1
+ %D = getelementptr inbounds [3 x float]* %C, i32 0, i32 2
+ %E = load float* %D, align 4
+ %F = fsub float %E, undef
+ ret void
+}
+