Home | History | Annotate | Download | only in InstCombine
      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:  %bc2 = bitcast i64 %a to <2 x i32>
     22 ; CHECK-NEXT:  ret <2 x i32> %bc2
     23 }
     24 
     25 define double @bitcast_bitcast_s_v_s(i64 %a) {
     26   %bc1 = bitcast i64 %a to <2 x i32>
     27   %bc2 = bitcast <2 x i32> %bc1 to double
     28   ret double %bc2
     29 
     30 ; CHECK-LABEL: @bitcast_bitcast_s_v_s(
     31 ; CHECK-NEXT:  %bc2 = bitcast i64 %a to double
     32 ; CHECK-NEXT:  ret double %bc2
     33 }
     34 
     35 define <2 x i32> @bitcast_bitcast_s_v_v(i64 %a) {
     36   %bc1 = bitcast i64 %a to <4 x i16>
     37   %bc2 = bitcast <4 x i16> %bc1 to <2 x i32>
     38   ret <2 x i32> %bc2
     39 
     40 ; CHECK-LABEL: @bitcast_bitcast_s_v_v(
     41 ; CHECK-NEXT:  %bc2 = bitcast i64 %a to <2 x i32>
     42 ; CHECK-NEXT:  ret <2 x i32> %bc2
     43 }
     44 
     45 define i64 @bitcast_bitcast_v_s_s(<2 x i32> %a) {
     46   %bc1 = bitcast <2 x i32> %a to double
     47   %bc2 = bitcast double %bc1 to i64
     48   ret i64 %bc2
     49 
     50 ; CHECK-LABEL: @bitcast_bitcast_v_s_s(
     51 ; CHECK-NEXT:  %bc2 = bitcast <2 x i32> %a to i64
     52 ; CHECK-NEXT:  ret i64 %bc2
     53 }
     54 
     55 define <4 x i16> @bitcast_bitcast_v_s_v(<2 x i32> %a) {
     56   %bc1 = bitcast <2 x i32> %a to double
     57   %bc2 = bitcast double %bc1 to <4 x i16>
     58   ret <4 x i16> %bc2
     59 
     60 ; CHECK-LABEL: @bitcast_bitcast_v_s_v(
     61 ; CHECK-NEXT:  %bc2 = bitcast <2 x i32> %a to <4 x i16>
     62 ; CHECK-NEXT:  ret <4 x i16> %bc2
     63 }
     64 
     65 define double @bitcast_bitcast_v_v_s(<2 x float> %a) {
     66   %bc1 = bitcast <2 x float> %a to <4 x i16>
     67   %bc2 = bitcast <4 x i16> %bc1 to double
     68   ret double %bc2
     69 
     70 ; CHECK-LABEL: @bitcast_bitcast_v_v_s(
     71 ; CHECK-NEXT:  %bc2 = bitcast <2 x float> %a to double
     72 ; CHECK-NEXT:  ret double %bc2
     73 }
     74 
     75 define <2 x i32> @bitcast_bitcast_v_v_v(<2 x float> %a) {
     76   %bc1 = bitcast <2 x float> %a to <4 x i16>
     77   %bc2 = bitcast <4 x i16> %bc1 to <2 x i32>
     78   ret <2 x i32> %bc2
     79 
     80 ; CHECK-LABEL: @bitcast_bitcast_v_v_v(
     81 ; CHECK-NEXT:  %bc2 = bitcast <2 x float> %a to <2 x i32>
     82 ; CHECK-NEXT:  ret <2 x i32> %bc2
     83 }
     84 
     85