blob: 3ddeb25b7d2ffc8f8c52f64a8c823cff0c040561 [file] [log] [blame]
Matt Arsenaulta9e95ab2013-11-15 05:45:08 +00001; RUN: opt -instcombine -S < %s | FileCheck %s
2
3target datalayout = "e-p:64:64:64-p1:32:32:32-p2:16:16:16-n8:16:32:64"
4
5define i32* @combine_redundant_addrspacecast(i32 addrspace(1)* %x) nounwind {
6; CHECK-LABEL: @combine_redundant_addrspacecast(
7; CHECK: addrspacecast i32 addrspace(1)* %x to i32*
8; CHECK-NEXT: ret
9 %y = addrspacecast i32 addrspace(1)* %x to i32 addrspace(3)*
10 %z = addrspacecast i32 addrspace(3)* %y to i32*
11 ret i32* %z
12}
13
14define <4 x i32*> @combine_redundant_addrspacecast_vector(<4 x i32 addrspace(1)*> %x) nounwind {
15; CHECK-LABEL: @combine_redundant_addrspacecast_vector(
16; CHECK: addrspacecast <4 x i32 addrspace(1)*> %x to <4 x i32*>
17; CHECK-NEXT: ret
18 %y = addrspacecast <4 x i32 addrspace(1)*> %x to <4 x i32 addrspace(3)*>
19 %z = addrspacecast <4 x i32 addrspace(3)*> %y to <4 x i32*>
20 ret <4 x i32*> %z
21}
22
23define float* @combine_redundant_addrspacecast_types(i32 addrspace(1)* %x) nounwind {
24; CHECK-LABEL: @combine_redundant_addrspacecast_types(
25; CHECK: addrspacecast i32 addrspace(1)* %x to float*
26; CHECK-NEXT: ret
27 %y = addrspacecast i32 addrspace(1)* %x to i32 addrspace(3)*
28 %z = addrspacecast i32 addrspace(3)* %y to float*
29 ret float* %z
30}
31