blob: 29511a3c6677b48e3069cff8017a397838e5c80c [file] [log] [blame]
Eli Bendersky9966b262014-04-03 17:51:58 +00001; RUN: opt < %s -instcombine -S | FileCheck %s
Nadav Rotema069c6c2011-04-05 14:29:52 +00002
Nadav Rotemcc771ac2011-04-06 11:18:29 +00003target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
4target triple = "x86_64-pc-win32"
5
Nadav Rotema069c6c2011-04-05 14:29:52 +00006%myStruct = type { float, [3 x float], [4 x float], i32 }
7
8; make sure that we are not crashing when creating an illegal type
9define void @func(%myStruct addrspace(1)* nocapture %p) nounwind {
10ST:
11 %A = getelementptr inbounds %myStruct addrspace(1)* %p, i64 0
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +000012 %B = addrspacecast %myStruct addrspace(1)* %A to %myStruct*
Nadav Rotema069c6c2011-04-05 14:29:52 +000013 %C = getelementptr inbounds %myStruct* %B, i32 0, i32 1
14 %D = getelementptr inbounds [3 x float]* %C, i32 0, i32 2
15 %E = load float* %D, align 4
16 %F = fsub float %E, undef
17 ret void
18}
19
Eli Bendersky9966b262014-04-03 17:51:58 +000020@array = internal addrspace(3) global [256 x float] zeroinitializer, align 4
21@scalar = internal addrspace(3) global float 0.000000e+00, align 4
22
23define void @keep_necessary_addrspacecast(i64 %i, float** %out0, float** %out1) {
24entry:
25; CHECK-LABEL: @keep_necessary_addrspacecast
26 %0 = getelementptr [256 x float]* addrspacecast ([256 x float] addrspace(3)* @array to [256 x float]*), i64 0, i64 %i
27; CHECK: addrspacecast float addrspace(3)* %{{[0-9]+}} to float*
28 %1 = getelementptr [0 x float]* addrspacecast (float addrspace(3)* @scalar to [0 x float]*), i64 0, i64 %i
29; CHECK: addrspacecast float addrspace(3)* %{{[0-9]+}} to float*
30 store float* %0, float** %out0, align 4
31 store float* %1, float** %out1, align 4
32 ret void
33}
34