Add tests for bitcast-bitcast sequences for all scalar/vector permutations
[oota-llvm.git] / test / Transforms / InstCombine / bitcast-bitcast.ll
1 ; RUN: opt < %s -instcombine -S | FileCheck %s
2
3 ; Check all scalar / vector combinations for a pair of bitcasts.
4
5 define ppc_fp128 @bitcast_bitcast_s_s_s(i128 %a) {
6   %bc1 = bitcast i128 %a to fp128
7   %bc2 = bitcast fp128 %bc1 to ppc_fp128
8   ret ppc_fp128 %bc2
9
10 ; CHECK-LABEL: @bitcast_bitcast_s_s_s(
11 ; CHECK-NEXT:  %bc2 = bitcast i128 %a to ppc_fp128
12 ; CHECK-NEXT:  ret ppc_fp128 %bc2
13 }
14
15 define <2 x i32> @bitcast_bitcast_s_s_v(i64 %a) {
16   %bc1 = bitcast i64 %a to double
17   %bc2 = bitcast double %bc1 to <2 x i32>
18   ret <2 x i32> %bc2
19
20 ; CHECK-LABEL: @bitcast_bitcast_s_s_v(
21 ; CHECK-NEXT:  %bc1 = bitcast i64 %a to double
22 ; CHECK-NEXT:  %bc2 = bitcast double %bc1 to <2 x i32>
23 ; CHECK-NEXT:  ret <2 x i32> %bc2
24 }
25
26 define double @bitcast_bitcast_s_v_s(i64 %a) {
27   %bc1 = bitcast i64 %a to <2 x i32>
28   %bc2 = bitcast <2 x i32> %bc1 to double
29   ret double %bc2
30
31 ; CHECK-LABEL: @bitcast_bitcast_s_v_s(
32 ; CHECK-NEXT:  %bc1 = bitcast i64 %a to <2 x i32>
33 ; CHECK-NEXT:  %bc2 = bitcast <2 x i32> %bc1 to double
34 ; CHECK-NEXT:  ret double %bc2
35 }
36
37 define <2 x i32> @bitcast_bitcast_s_v_v(i64 %a) {
38   %bc1 = bitcast i64 %a to <4 x i16>
39   %bc2 = bitcast <4 x i16> %bc1 to <2 x i32>
40   ret <2 x i32> %bc2
41
42 ; CHECK-LABEL: @bitcast_bitcast_s_v_v(
43 ; CHECK-NEXT:  %bc1 = bitcast i64 %a to <4 x i16>
44 ; CHECK-NEXT:  %bc2 = bitcast <4 x i16> %bc1 to <2 x i32>
45 ; CHECK-NEXT:  ret <2 x i32> %bc2
46 }
47
48 define i64 @bitcast_bitcast_v_s_s(<2 x i32> %a) {
49   %bc1 = bitcast <2 x i32> %a to double
50   %bc2 = bitcast double %bc1 to i64
51   ret i64 %bc2
52
53 ; CHECK-LABEL: @bitcast_bitcast_v_s_s(
54 ; CHECK-NEXT:  %bc1 = bitcast <2 x i32> %a to double
55 ; CHECK-NEXT:  %bc2 = bitcast double %bc1 to i64
56 ; CHECK-NEXT:  ret i64 %bc2
57 }
58
59 define <4 x i16> @bitcast_bitcast_v_s_v(<2 x i32> %a) {
60   %bc1 = bitcast <2 x i32> %a to double
61   %bc2 = bitcast double %bc1 to <4 x i16>
62   ret <4 x i16> %bc2
63
64 ; CHECK-LABEL: @bitcast_bitcast_v_s_v(
65 ; CHECK-NEXT:  %bc1 = bitcast <2 x i32> %a to double
66 ; CHECK-NEXT:  %bc2 = bitcast double %bc1 to <4 x i16>
67 ; CHECK-NEXT:  ret <4 x i16> %bc2
68 }
69
70 define double @bitcast_bitcast_v_v_s(<2 x float> %a) {
71   %bc1 = bitcast <2 x float> %a to <4 x i16>
72   %bc2 = bitcast <4 x i16> %bc1 to double
73   ret double %bc2
74
75 ; CHECK-LABEL: @bitcast_bitcast_v_v_s(
76 ; CHECK-NEXT:  %bc1 = bitcast <2 x float> %a to <4 x i16>
77 ; CHECK-NEXT:  %bc2 = bitcast <4 x i16> %bc1 to double
78 ; CHECK-NEXT:  ret double %bc2
79 }
80
81 define <2 x i32> @bitcast_bitcast_v_v_v(<2 x float> %a) {
82   %bc1 = bitcast <2 x float> %a to <4 x i16>
83   %bc2 = bitcast <4 x i16> %bc1 to <2 x i32>
84   ret <2 x i32> %bc2
85
86 ; CHECK-LABEL: @bitcast_bitcast_v_v_v(
87 ; CHECK-NEXT:  %bc2 = bitcast <2 x float> %a to <2 x i32>
88 ; CHECK-NEXT:  ret <2 x i32> %bc2
89 }
90