Home | History | Annotate | Download | only in InstCombine
      1 ; RUN: opt -S -instcombine %s | FileCheck %s
      2 
      3 ; CHECK-LABEL: julia_2xdouble
      4 ; CHECK-NOT: insertvalue
      5 ; CHECK-NOT: extractelement
      6 ; CHECK: store <2 x double>
      7 define void @julia_2xdouble([2 x double]* sret, <2 x double>*) {
      8 top:
      9   %x = load <2 x double>, <2 x double>* %1
     10   %x0 = extractelement <2 x double> %x, i32 0
     11   %i0 = insertvalue [2 x double] undef, double %x0, 0
     12   %x1 = extractelement <2 x double> %x, i32 1
     13   %i1 = insertvalue [2 x double] %i0, double %x1, 1
     14   store [2 x double] %i1, [2 x double]* %0, align 4
     15   ret void
     16 }
     17 
     18 ; Test with two inserts to the same index
     19 ; CHECK-LABEL: julia_2xi64
     20 ; CHECK-NOT: insertvalue
     21 ; CHECK-NOT: extractelement
     22 ; CHECK: store <2 x i64>
     23 define void @julia_2xi64([2 x i64]* sret, <2 x i64>*) {
     24 top:
     25   %x = load <2 x i64>, <2 x i64>* %1
     26   %x0 = extractelement <2 x i64> %x, i32 1
     27   %i0 = insertvalue [2 x i64] undef, i64 %x0, 0
     28   %x1 = extractelement <2 x i64> %x, i32 1
     29   %i1 = insertvalue [2 x i64] %i0, i64 %x1, 1
     30   %x2 = extractelement <2 x i64> %x, i32 0
     31   %i2 = insertvalue [2 x i64] %i1, i64 %x2, 0
     32   store [2 x i64] %i2, [2 x i64]* %0, align 4
     33   ret void
     34 }
     35 
     36 ; CHECK-LABEL: julia_4xfloat
     37 ; CHECK-NOT: insertvalue
     38 ; CHECK-NOT: extractelement
     39 ; CHECK: store <4 x float>
     40 define void @julia_4xfloat([4 x float]* sret, <4 x float>*) {
     41 top:
     42   %x = load <4 x float>, <4 x float>* %1
     43   %x0 = extractelement <4 x float> %x, i32 0
     44   %i0 = insertvalue [4 x float] undef, float %x0, 0
     45   %x1 = extractelement <4 x float> %x, i32 1
     46   %i1 = insertvalue [4 x float] %i0, float %x1, 1
     47   %x2 = extractelement <4 x float> %x, i32 2
     48   %i2 = insertvalue [4 x float] %i1, float %x2, 2
     49   %x3 = extractelement <4 x float> %x, i32 3
     50   %i3 = insertvalue [4 x float] %i2, float %x3, 3
     51   store [4 x float] %i3, [4 x float]* %0, align 4
     52   ret void
     53 }
     54 
     55 %pseudovec = type { float, float, float, float }
     56 
     57 ; CHECK-LABEL: julia_pseudovec
     58 ; CHECK-NOT: insertvalue
     59 ; CHECK-NOT: extractelement
     60 ; CHECK: store <4 x float>
     61 define void @julia_pseudovec(%pseudovec* sret, <4 x float>*) {
     62 top:
     63   %x = load <4 x float>, <4 x float>* %1
     64   %x0 = extractelement <4 x float> %x, i32 0
     65   %i0 = insertvalue %pseudovec undef, float %x0, 0
     66   %x1 = extractelement <4 x float> %x, i32 1
     67   %i1 = insertvalue %pseudovec %i0, float %x1, 1
     68   %x2 = extractelement <4 x float> %x, i32 2
     69   %i2 = insertvalue %pseudovec %i1, float %x2, 2
     70   %x3 = extractelement <4 x float> %x, i32 3
     71   %i3 = insertvalue %pseudovec %i2, float %x3, 3
     72   store %pseudovec %i3, %pseudovec* %0, align 4
     73   ret void
     74 }
     75