1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -instcombine -S < %s | FileCheck %s
; CHECK-LABEL: good1
; CHECK: %[[INS:.*]] = insertelement <4 x float> undef, float %arg, i32 0
; CHECK-NEXT: %[[BCAST:.*]] = shufflevector <4 x float> %[[INS]], <4 x float> undef, <4 x i32> zeroinitializer
; CHECK-NEXT: ret <4 x float> %[[BCAST]]
define <4 x float> @good1(float %arg) {
%tmp = insertelement <4 x float> undef, float %arg, i32 0
%tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1
%tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2
%tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
ret <4 x float> %tmp6
}
; CHECK-LABEL: good2
; CHECK: %[[INS:.*]] = insertelement <4 x float> undef, float %arg, i32 0
; CHECK-NEXT: %[[BCAST:.*]] = shufflevector <4 x float> %[[INS]], <4 x float> undef, <4 x i32> zeroinitializer
; CHECK-NEXT: ret <4 x float> %[[BCAST]]
define <4 x float> @good2(float %arg) {
%tmp = insertelement <4 x float> undef, float %arg, i32 1
%tmp4 = insertelement <4 x float> %tmp, float %arg, i32 2
%tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 0
%tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
ret <4 x float> %tmp6
}
; CHECK-LABEL: good3
; CHECK: %[[INS:.*]] = insertelement <4 x float> undef, float %arg, i32 0
; CHECK-NEXT: %[[BCAST:.*]] = shufflevector <4 x float> %[[INS]], <4 x float> undef, <4 x i32> zeroinitializer
; CHECK-NEXT: ret <4 x float> %[[BCAST]]
define <4 x float> @good3(float %arg) {
%tmp = insertelement <4 x float> zeroinitializer, float %arg, i32 0
%tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1
%tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2
%tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
ret <4 x float> %tmp6
}
; CHECK-LABEL: good4
; CHECK: %[[INS:.*]] = insertelement <4 x float> undef, float %arg, i32 0
; CHECK-NEXT: %[[ADD:.*]] = fadd <4 x float> %[[INS]], %[[INS]]
; CHECK-NEXT: %[[BCAST:.*]] = shufflevector <4 x float> %[[ADD]], <4 x float> undef, <4 x i32> zeroinitializer
; CHECK-NEXT: ret <4 x float> %[[BCAST]]
define <4 x float> @good4(float %arg) {
%tmp = insertelement <4 x float> zeroinitializer, float %arg, i32 0
%tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1
%tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2
%tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
%tmp7 = fadd <4 x float> %tmp6, %tmp6
ret <4 x float> %tmp7
}
; CHECK-LABEL: @good5(
; CHECK-NEXT: %ins1 = insertelement <4 x float> undef, float %v, i32 0
; CHECK-NEXT: %a1 = fadd <4 x float> %ins1, %ins1
; CHECK-NEXT: %ins4 = shufflevector <4 x float> %ins1, <4 x float> undef, <4 x i32> zeroinitializer
; CHECK-NEXT: %res = fadd <4 x float> %a1, %ins4
; CHECK-NEXT: ret <4 x float> %res
define <4 x float> @good5(float %v) {
%ins1 = insertelement <4 x float> undef, float %v, i32 0
%a1 = fadd <4 x float> %ins1, %ins1
%ins2 = insertelement<4 x float> %ins1, float %v, i32 1
%ins3 = insertelement<4 x float> %ins2, float %v, i32 2
%ins4 = insertelement<4 x float> %ins3, float %v, i32 3
%res = fadd <4 x float> %a1, %ins4
ret <4 x float> %res
}
; CHECK-LABEL: bad1
; CHECK-NOT: shufflevector
define <4 x float> @bad1(float %arg) {
%tmp = insertelement <4 x float> undef, float %arg, i32 1
%tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1
%tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2
%tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
ret <4 x float> %tmp6
}
; CHECK-LABEL: bad2
; CHECK-NOT: shufflevector
define <4 x float> @bad2(float %arg) {
%tmp = insertelement <4 x float> undef, float %arg, i32 0
%tmp5 = insertelement <4 x float> %tmp, float %arg, i32 2
%tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
ret <4 x float> %tmp6
}
; CHECK-LABEL: bad3
; CHECK-NOT: shufflevector
define <4 x float> @bad3(float %arg, float %arg2) {
%tmp = insertelement <4 x float> undef, float %arg, i32 0
%tmp4 = insertelement <4 x float> %tmp, float %arg2, i32 1
%tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2
%tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
ret <4 x float> %tmp6
}
; CHECK-LABEL: bad4
; CHECK-NOT: shufflevector
define <1 x float> @bad4(float %arg) {
%tmp = insertelement <1 x float> undef, float %arg, i32 0
ret <1 x float> %tmp
}
; CHECK-LABEL: bad5
; CHECK-NOT: shufflevector
define <4 x float> @bad5(float %arg) {
%tmp = insertelement <4 x float> undef, float %arg, i32 0
%tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1
%tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2
%tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
%tmp7 = fadd <4 x float> %tmp6, %tmp4
ret <4 x float> %tmp7
}
; CHECK-LABEL: bad6
; CHECK-NOT: shufflevector
define <4 x float> @bad6(float %arg, i32 %k) {
%tmp = insertelement <4 x float> undef, float %arg, i32 0
%tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1
%tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 %k
%tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
ret <4 x float> %tmp6
}
; CHECK-LABEL: @bad7(
; CHECK-NOT: shufflevector
define <4 x float> @bad7(float %v) {
%ins1 = insertelement <4 x float> undef, float %v, i32 1
%a1 = fadd <4 x float> %ins1, %ins1
%ins2 = insertelement<4 x float> %ins1, float %v, i32 2
%ins3 = insertelement<4 x float> %ins2, float %v, i32 3
%ins4 = insertelement<4 x float> %ins3, float %v, i32 0
%res = fadd <4 x float> %a1, %ins4
ret <4 x float> %res
}
|