2019-04-17 12:52:47 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
|
|
; RUN: opt -instcombine -S < %s | FileCheck %s
|
|
|
|
|
|
|
|
define <4 x float> @good1(float %arg) {
|
2019-06-26 23:24:08 +08:00
|
|
|
; CHECK-LABEL: @good1(
|
2019-06-27 02:06:51 +08:00
|
|
|
; CHECK-NEXT: [[TMP:%.*]] = insertelement <4 x float> undef, float [[ARG:%.*]], i32 0
|
|
|
|
; CHECK-NEXT: [[TMP6:%.*]] = shufflevector <4 x float> [[TMP]], <4 x float> undef, <4 x i32> zeroinitializer
|
|
|
|
; CHECK-NEXT: ret <4 x float> [[TMP6]]
|
2019-06-26 23:24:08 +08:00
|
|
|
;
|
2019-06-27 02:06:51 +08:00
|
|
|
%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
|
2019-04-17 12:52:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x float> @good2(float %arg) {
|
2019-06-26 23:24:08 +08:00
|
|
|
; CHECK-LABEL: @good2(
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x float> undef, float [[ARG:%.*]], i32 0
|
2019-06-27 02:06:51 +08:00
|
|
|
; CHECK-NEXT: [[TMP6:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> undef, <4 x i32> zeroinitializer
|
|
|
|
; CHECK-NEXT: ret <4 x float> [[TMP6]]
|
2019-06-26 23:24:08 +08:00
|
|
|
;
|
2019-06-27 02:06:51 +08:00
|
|
|
%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
|
2019-04-17 12:52:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x float> @good3(float %arg) {
|
2019-06-26 23:24:08 +08:00
|
|
|
; CHECK-LABEL: @good3(
|
2019-06-27 02:06:51 +08:00
|
|
|
; CHECK-NEXT: [[TMP:%.*]] = insertelement <4 x float> undef, float [[ARG:%.*]], i32 0
|
|
|
|
; CHECK-NEXT: [[TMP6:%.*]] = shufflevector <4 x float> [[TMP]], <4 x float> undef, <4 x i32> zeroinitializer
|
|
|
|
; CHECK-NEXT: ret <4 x float> [[TMP6]]
|
2019-06-26 23:24:08 +08:00
|
|
|
;
|
2019-06-27 02:06:51 +08:00
|
|
|
%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
|
2019-04-17 12:52:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x float> @good4(float %arg) {
|
2019-06-26 23:24:08 +08:00
|
|
|
; CHECK-LABEL: @good4(
|
2019-06-27 02:06:51 +08:00
|
|
|
; CHECK-NEXT: [[TMP:%.*]] = insertelement <4 x float> undef, float [[ARG:%.*]], i32 0
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = fadd <4 x float> [[TMP]], [[TMP]]
|
|
|
|
; CHECK-NEXT: [[TMP7:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> undef, <4 x i32> zeroinitializer
|
|
|
|
; CHECK-NEXT: ret <4 x float> [[TMP7]]
|
2019-06-26 23:24:08 +08:00
|
|
|
;
|
2019-06-27 02:06:51 +08:00
|
|
|
%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
|
2019-04-17 12:52:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x float> @good5(float %v) {
|
2019-06-26 23:24:08 +08:00
|
|
|
; 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]]
|
|
|
|
;
|
2019-04-17 12:52:47 +08:00
|
|
|
%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
|
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x float> @bad1(float %arg) {
|
2019-06-26 23:24:08 +08:00
|
|
|
; CHECK-LABEL: @bad1(
|
2019-06-27 02:06:51 +08:00
|
|
|
; CHECK-NEXT: [[TMP4:%.*]] = insertelement <4 x float> undef, float [[ARG:%.*]], i32 1
|
|
|
|
; CHECK-NEXT: [[TMP5:%.*]] = insertelement <4 x float> [[TMP4]], float [[ARG]], i32 2
|
|
|
|
; CHECK-NEXT: [[TMP6:%.*]] = insertelement <4 x float> [[TMP5]], float [[ARG]], i32 3
|
|
|
|
; CHECK-NEXT: ret <4 x float> [[TMP6]]
|
2019-06-26 23:24:08 +08:00
|
|
|
;
|
2019-06-27 02:06:51 +08:00
|
|
|
%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
|
2019-04-17 12:52:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x float> @bad2(float %arg) {
|
2019-06-26 23:24:08 +08:00
|
|
|
; CHECK-LABEL: @bad2(
|
2019-06-27 02:06:51 +08:00
|
|
|
; CHECK-NEXT: [[TMP:%.*]] = insertelement <4 x float> undef, float [[ARG:%.*]], i32 0
|
|
|
|
; CHECK-NEXT: [[TMP5:%.*]] = insertelement <4 x float> [[TMP]], float [[ARG]], i32 2
|
|
|
|
; CHECK-NEXT: [[TMP6:%.*]] = insertelement <4 x float> [[TMP5]], float [[ARG]], i32 3
|
|
|
|
; CHECK-NEXT: ret <4 x float> [[TMP6]]
|
2019-06-26 23:24:08 +08:00
|
|
|
;
|
2019-06-27 02:06:51 +08:00
|
|
|
%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
|
2019-04-17 12:52:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x float> @bad3(float %arg, float %arg2) {
|
2019-06-26 23:24:08 +08:00
|
|
|
; CHECK-LABEL: @bad3(
|
2019-06-27 02:06:51 +08:00
|
|
|
; CHECK-NEXT: [[TMP:%.*]] = insertelement <4 x float> undef, float [[ARG:%.*]], i32 0
|
|
|
|
; CHECK-NEXT: [[TMP4:%.*]] = insertelement <4 x float> [[TMP]], float [[ARG2:%.*]], i32 1
|
|
|
|
; CHECK-NEXT: [[TMP5:%.*]] = insertelement <4 x float> [[TMP4]], float [[ARG]], i32 2
|
|
|
|
; CHECK-NEXT: [[TMP6:%.*]] = insertelement <4 x float> [[TMP5]], float [[ARG]], i32 3
|
|
|
|
; CHECK-NEXT: ret <4 x float> [[TMP6]]
|
2019-06-26 23:24:08 +08:00
|
|
|
;
|
2019-06-27 02:06:51 +08:00
|
|
|
%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
|
2019-04-17 12:52:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define <1 x float> @bad4(float %arg) {
|
2019-06-26 23:24:08 +08:00
|
|
|
; CHECK-LABEL: @bad4(
|
2019-06-27 02:06:51 +08:00
|
|
|
; CHECK-NEXT: [[TMP:%.*]] = insertelement <1 x float> undef, float [[ARG:%.*]], i32 0
|
|
|
|
; CHECK-NEXT: ret <1 x float> [[TMP]]
|
2019-06-26 23:24:08 +08:00
|
|
|
;
|
2019-06-27 02:06:51 +08:00
|
|
|
%tmp = insertelement <1 x float> undef, float %arg, i32 0
|
|
|
|
ret <1 x float> %tmp
|
2019-04-17 12:52:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x float> @bad5(float %arg) {
|
2019-06-26 23:24:08 +08:00
|
|
|
; CHECK-LABEL: @bad5(
|
2019-06-27 02:06:51 +08:00
|
|
|
; CHECK-NEXT: [[TMP:%.*]] = insertelement <4 x float> undef, float [[ARG:%.*]], i32 0
|
|
|
|
; CHECK-NEXT: [[TMP4:%.*]] = insertelement <4 x float> [[TMP]], float [[ARG]], i32 1
|
|
|
|
; CHECK-NEXT: [[TMP5:%.*]] = insertelement <4 x float> [[TMP4]], float [[ARG]], i32 2
|
|
|
|
; CHECK-NEXT: [[TMP6:%.*]] = insertelement <4 x float> [[TMP5]], float [[ARG]], i32 3
|
|
|
|
; CHECK-NEXT: [[TMP7:%.*]] = fadd <4 x float> [[TMP6]], [[TMP4]]
|
|
|
|
; CHECK-NEXT: ret <4 x float> [[TMP7]]
|
2019-06-26 23:24:08 +08:00
|
|
|
;
|
2019-06-27 02:06:51 +08:00
|
|
|
%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
|
2019-04-17 12:52:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x float> @bad6(float %arg, i32 %k) {
|
2019-06-26 23:24:08 +08:00
|
|
|
; CHECK-LABEL: @bad6(
|
2019-06-27 02:06:51 +08:00
|
|
|
; CHECK-NEXT: [[TMP:%.*]] = insertelement <4 x float> undef, float [[ARG:%.*]], i32 0
|
|
|
|
; CHECK-NEXT: [[TMP4:%.*]] = insertelement <4 x float> [[TMP]], float [[ARG]], i32 1
|
|
|
|
; CHECK-NEXT: [[TMP5:%.*]] = insertelement <4 x float> [[TMP4]], float [[ARG]], i32 [[K:%.*]]
|
|
|
|
; CHECK-NEXT: [[TMP6:%.*]] = insertelement <4 x float> [[TMP5]], float [[ARG]], i32 3
|
|
|
|
; CHECK-NEXT: ret <4 x float> [[TMP6]]
|
2019-06-26 23:24:08 +08:00
|
|
|
;
|
2019-06-27 02:06:51 +08:00
|
|
|
%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
|
2019-04-17 12:52:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x float> @bad7(float %v) {
|
2019-06-26 23:24:08 +08:00
|
|
|
; CHECK-LABEL: @bad7(
|
|
|
|
; CHECK-NEXT: [[INS1:%.*]] = insertelement <4 x float> undef, float [[V:%.*]], i32 1
|
|
|
|
; CHECK-NEXT: [[A1:%.*]] = fadd <4 x float> [[INS1]], [[INS1]]
|
|
|
|
; CHECK-NEXT: [[INS2:%.*]] = insertelement <4 x float> [[INS1]], float [[V]], i32 2
|
|
|
|
; CHECK-NEXT: [[INS3:%.*]] = insertelement <4 x float> [[INS2]], float [[V]], i32 3
|
|
|
|
; CHECK-NEXT: [[INS4:%.*]] = insertelement <4 x float> [[INS3]], float [[V]], i32 0
|
|
|
|
; CHECK-NEXT: [[RES:%.*]] = fadd <4 x float> [[A1]], [[INS4]]
|
|
|
|
; CHECK-NEXT: ret <4 x float> [[RES]]
|
|
|
|
;
|
2019-04-17 12:52:47 +08:00
|
|
|
%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
|
|
|
|
}
|