forked from OSchip/llvm-project
[Constant] Update ConstantVector::get to return poison if all input elems are poison
The diff was reviewed at D93994
This commit is contained in:
parent
8deaec122e
commit
8871a4b4ca
|
@ -1339,17 +1339,20 @@ Constant *ConstantVector::getImpl(ArrayRef<Constant*> V) {
|
|||
Constant *C = V[0];
|
||||
bool isZero = C->isNullValue();
|
||||
bool isUndef = isa<UndefValue>(C);
|
||||
bool isPoison = isa<PoisonValue>(C);
|
||||
|
||||
if (isZero || isUndef) {
|
||||
for (unsigned i = 1, e = V.size(); i != e; ++i)
|
||||
if (V[i] != C) {
|
||||
isZero = isUndef = false;
|
||||
isZero = isUndef = isPoison = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isZero)
|
||||
return ConstantAggregateZero::get(T);
|
||||
if (isPoison)
|
||||
return PoisonValue::get(T);
|
||||
if (isUndef)
|
||||
return UndefValue::get(T);
|
||||
|
||||
|
|
|
@ -244,7 +244,7 @@ define <16 x i8> @elts_packsswb_128(<8 x i16> %a0, <8 x i16> %a1) {
|
|||
|
||||
define <16 x i8> @elts_packuswb_128(<8 x i16> %a0, <8 x i16> %a1) {
|
||||
; CHECK-LABEL: @elts_packuswb_128(
|
||||
; CHECK-NEXT: ret <16 x i8> undef
|
||||
; CHECK-NEXT: ret <16 x i8> poison
|
||||
;
|
||||
%1 = insertelement <8 x i16> poison, i16 0, i32 0
|
||||
%2 = insertelement <8 x i16> poison, i16 0, i32 0
|
||||
|
@ -293,7 +293,7 @@ define <32 x i8> @elts_packsswb_256(<16 x i16> %a0, <16 x i16> %a1) {
|
|||
|
||||
define <32 x i8> @elts_packuswb_256(<16 x i16> %a0, <16 x i16> %a1) {
|
||||
; CHECK-LABEL: @elts_packuswb_256(
|
||||
; CHECK-NEXT: ret <32 x i8> undef
|
||||
; CHECK-NEXT: ret <32 x i8> poison
|
||||
;
|
||||
%1 = insertelement <16 x i16> poison, i16 0, i32 1
|
||||
%2 = insertelement <16 x i16> poison, i16 0, i32 0
|
||||
|
@ -344,7 +344,7 @@ define <64 x i8> @elts_packsswb_512(<32 x i16> %a0, <32 x i16> %a1) {
|
|||
|
||||
define <64 x i8> @elts_packuswb_512(<32 x i16> %a0, <32 x i16> %a1) {
|
||||
; CHECK-LABEL: @elts_packuswb_512(
|
||||
; CHECK-NEXT: ret <64 x i8> undef
|
||||
; CHECK-NEXT: ret <64 x i8> poison
|
||||
;
|
||||
%1 = insertelement <32 x i16> poison, i16 0, i32 1
|
||||
%2 = insertelement <32 x i16> poison, i16 0, i32 0
|
||||
|
|
|
@ -27,7 +27,7 @@ define <4 x i32> @square(<4 x i32> %num, i32 %y, i32 %x, i32 %h, i32 %k, i32 %w,
|
|||
; CHECK-NEXT: [[DOTSCALAR6:%.*]] = add i32 [[DOTSCALAR5]], [[DIV9]]
|
||||
; CHECK-NEXT: [[DOTSCALAR7:%.*]] = add i32 [[DOTSCALAR6]], [[MUL21]]
|
||||
; CHECK-NEXT: [[DOTSCALAR8:%.*]] = add i32 [[DOTSCALAR7]], 317425
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x i32> undef, i32 [[DOTSCALAR8]], i64 0
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x i32> poison, i32 [[DOTSCALAR8]], i64 0
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <4 x i32> zeroinitializer
|
||||
; CHECK-NEXT: [[ADD29:%.*]] = add <4 x i32> [[TMP2]], [[NUM:%.*]]
|
||||
; CHECK-NEXT: ret <4 x i32> [[ADD29]]
|
||||
|
|
|
@ -425,7 +425,7 @@ define <8 x i32> @sdiv_v8i32_undefs(<8 x i32> %a) {
|
|||
; CHECK-NEXT: [[AB5:%.*]] = sdiv i32 [[A5]], 4
|
||||
; CHECK-NEXT: [[AB6:%.*]] = sdiv i32 [[A6]], 8
|
||||
; CHECK-NEXT: [[AB7:%.*]] = sdiv i32 [[A7]], 16
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <8 x i32> <i32 undef, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>, i32 [[AB1]], i32 1
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <8 x i32> poison, i32 [[AB1]], i32 1
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = insertelement <8 x i32> [[TMP1]], i32 [[AB2]], i32 2
|
||||
; CHECK-NEXT: [[R4:%.*]] = insertelement <8 x i32> [[TMP2]], i32 [[AB3]], i32 3
|
||||
; CHECK-NEXT: [[R5:%.*]] = insertelement <8 x i32> [[R4]], i32 [[AB5]], i32 5
|
||||
|
|
|
@ -425,7 +425,7 @@ define <8 x i32> @sdiv_v8i32_undefs(<8 x i32> %a) {
|
|||
; CHECK-NEXT: [[AB5:%.*]] = sdiv i32 [[A5]], 4
|
||||
; CHECK-NEXT: [[AB6:%.*]] = sdiv i32 [[A6]], 8
|
||||
; CHECK-NEXT: [[AB7:%.*]] = sdiv i32 [[A7]], 16
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <8 x i32> undef, i32 [[AB1]], i32 1
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <8 x i32> poison, i32 [[AB1]], i32 1
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = insertelement <8 x i32> [[TMP1]], i32 [[AB2]], i32 2
|
||||
; CHECK-NEXT: [[R4:%.*]] = insertelement <8 x i32> [[TMP2]], i32 [[AB3]], i32 3
|
||||
; CHECK-NEXT: [[R5:%.*]] = insertelement <8 x i32> [[R4]], i32 [[AB5]], i32 5
|
||||
|
|
|
@ -131,7 +131,7 @@ define <16 x i8> @mul_constant_multiuse(i8 %a0, <16 x i8> %a1) {
|
|||
define <2 x i64> @shl_constant_op0(i64 %x) {
|
||||
; CHECK-LABEL: @shl_constant_op0(
|
||||
; CHECK-NEXT: [[BO_SCALAR:%.*]] = shl i64 2, [[X:%.*]]
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 1
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 1
|
||||
; CHECK-NEXT: ret <2 x i64> [[BO]]
|
||||
;
|
||||
%ins = insertelement <2 x i64> undef, i64 %x, i32 1
|
||||
|
@ -142,7 +142,7 @@ define <2 x i64> @shl_constant_op0(i64 %x) {
|
|||
define <2 x i64> @shl_constant_op0_not_undef_lane(i64 %x) {
|
||||
; CHECK-LABEL: @shl_constant_op0_not_undef_lane(
|
||||
; CHECK-NEXT: [[BO_SCALAR:%.*]] = shl i64 2, [[X:%.*]]
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 1
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 1
|
||||
; CHECK-NEXT: ret <2 x i64> [[BO]]
|
||||
;
|
||||
%ins = insertelement <2 x i64> undef, i64 %x, i32 1
|
||||
|
@ -224,7 +224,7 @@ define <2 x i64> @shl_constant_op1_load(i64* %p) {
|
|||
define <2 x i64> @ashr_constant_op0(i64 %x) {
|
||||
; CHECK-LABEL: @ashr_constant_op0(
|
||||
; CHECK-NEXT: [[BO_SCALAR:%.*]] = ashr exact i64 2, [[X:%.*]]
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 1
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 1
|
||||
; CHECK-NEXT: ret <2 x i64> [[BO]]
|
||||
;
|
||||
%ins = insertelement <2 x i64> undef, i64 %x, i32 1
|
||||
|
@ -235,7 +235,7 @@ define <2 x i64> @ashr_constant_op0(i64 %x) {
|
|||
define <2 x i64> @ashr_constant_op0_not_undef_lane(i64 %x) {
|
||||
; CHECK-LABEL: @ashr_constant_op0_not_undef_lane(
|
||||
; CHECK-NEXT: [[BO_SCALAR:%.*]] = ashr exact i64 2, [[X:%.*]]
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 1
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 1
|
||||
; CHECK-NEXT: ret <2 x i64> [[BO]]
|
||||
;
|
||||
%ins = insertelement <2 x i64> undef, i64 %x, i32 1
|
||||
|
@ -268,7 +268,7 @@ define <2 x i64> @ashr_constant_op1_not_undef_lane(i64 %x) {
|
|||
define <2 x i64> @lshr_constant_op0(i64 %x) {
|
||||
; CHECK-LABEL: @lshr_constant_op0(
|
||||
; CHECK-NEXT: [[BO_SCALAR:%.*]] = lshr i64 5, [[X:%.*]]
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: ret <2 x i64> [[BO]]
|
||||
;
|
||||
%ins = insertelement <2 x i64> undef, i64 %x, i32 0
|
||||
|
@ -279,7 +279,7 @@ define <2 x i64> @lshr_constant_op0(i64 %x) {
|
|||
define <2 x i64> @lshr_constant_op0_not_undef_lane(i64 %x) {
|
||||
; CHECK-LABEL: @lshr_constant_op0_not_undef_lane(
|
||||
; CHECK-NEXT: [[BO_SCALAR:%.*]] = lshr i64 5, [[X:%.*]]
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: ret <2 x i64> [[BO]]
|
||||
;
|
||||
%ins = insertelement <2 x i64> undef, i64 %x, i32 0
|
||||
|
@ -312,7 +312,7 @@ define <2 x i64> @lshr_constant_op1_not_undef_lane(i64 %x) {
|
|||
define <2 x i64> @urem_constant_op0(i64 %x) {
|
||||
; CHECK-LABEL: @urem_constant_op0(
|
||||
; CHECK-NEXT: [[BO_SCALAR:%.*]] = urem i64 5, [[X:%.*]]
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: ret <2 x i64> [[BO]]
|
||||
;
|
||||
%ins = insertelement <2 x i64> undef, i64 %x, i32 0
|
||||
|
@ -323,7 +323,7 @@ define <2 x i64> @urem_constant_op0(i64 %x) {
|
|||
define <2 x i64> @urem_constant_op0_not_undef_lane(i64 %x) {
|
||||
; CHECK-LABEL: @urem_constant_op0_not_undef_lane(
|
||||
; CHECK-NEXT: [[BO_SCALAR:%.*]] = urem i64 5, [[X:%.*]]
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: ret <2 x i64> [[BO]]
|
||||
;
|
||||
%ins = insertelement <2 x i64> undef, i64 %x, i32 0
|
||||
|
@ -356,7 +356,7 @@ define <2 x i64> @urem_constant_op1_not_undef_lane(i64 %x) {
|
|||
define <2 x i64> @srem_constant_op0(i64 %x) {
|
||||
; CHECK-LABEL: @srem_constant_op0(
|
||||
; CHECK-NEXT: [[BO_SCALAR:%.*]] = srem i64 5, [[X:%.*]]
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: ret <2 x i64> [[BO]]
|
||||
;
|
||||
%ins = insertelement <2 x i64> undef, i64 %x, i32 0
|
||||
|
@ -367,7 +367,7 @@ define <2 x i64> @srem_constant_op0(i64 %x) {
|
|||
define <2 x i64> @srem_constant_op0_not_undef_lane(i64 %x) {
|
||||
; CHECK-LABEL: @srem_constant_op0_not_undef_lane(
|
||||
; CHECK-NEXT: [[BO_SCALAR:%.*]] = srem i64 5, [[X:%.*]]
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: ret <2 x i64> [[BO]]
|
||||
;
|
||||
%ins = insertelement <2 x i64> undef, i64 %x, i32 0
|
||||
|
@ -400,7 +400,7 @@ define <2 x i64> @srem_constant_op1_not_undef_lane(i64 %x) {
|
|||
define <2 x i64> @udiv_constant_op0(i64 %x) {
|
||||
; CHECK-LABEL: @udiv_constant_op0(
|
||||
; CHECK-NEXT: [[BO_SCALAR:%.*]] = udiv exact i64 5, [[X:%.*]]
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: ret <2 x i64> [[BO]]
|
||||
;
|
||||
%ins = insertelement <2 x i64> undef, i64 %x, i32 0
|
||||
|
@ -411,7 +411,7 @@ define <2 x i64> @udiv_constant_op0(i64 %x) {
|
|||
define <2 x i64> @udiv_constant_op0_not_undef_lane(i64 %x) {
|
||||
; CHECK-LABEL: @udiv_constant_op0_not_undef_lane(
|
||||
; CHECK-NEXT: [[BO_SCALAR:%.*]] = udiv exact i64 5, [[X:%.*]]
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: ret <2 x i64> [[BO]]
|
||||
;
|
||||
%ins = insertelement <2 x i64> undef, i64 %x, i32 0
|
||||
|
@ -444,7 +444,7 @@ define <2 x i64> @udiv_constant_op1_not_undef_lane(i64 %x) {
|
|||
define <2 x i64> @sdiv_constant_op0(i64 %x) {
|
||||
; CHECK-LABEL: @sdiv_constant_op0(
|
||||
; CHECK-NEXT: [[BO_SCALAR:%.*]] = sdiv i64 5, [[X:%.*]]
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: ret <2 x i64> [[BO]]
|
||||
;
|
||||
%ins = insertelement <2 x i64> undef, i64 %x, i32 0
|
||||
|
@ -455,7 +455,7 @@ define <2 x i64> @sdiv_constant_op0(i64 %x) {
|
|||
define <2 x i64> @sdiv_constant_op0_not_undef_lane(i64 %x) {
|
||||
; CHECK-LABEL: @sdiv_constant_op0_not_undef_lane(
|
||||
; CHECK-NEXT: [[BO_SCALAR:%.*]] = sdiv i64 5, [[X:%.*]]
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
|
||||
; CHECK-NEXT: ret <2 x i64> [[BO]]
|
||||
;
|
||||
%ins = insertelement <2 x i64> undef, i64 %x, i32 0
|
||||
|
|
|
@ -53,7 +53,7 @@ define <2 x i64> @ins1_ins1_iterate(i64 %w, i64 %x, i64 %y, i64 %z) {
|
|||
; CHECK-NEXT: [[S0_SCALAR:%.*]] = sub i64 [[W:%.*]], [[X:%.*]]
|
||||
; CHECK-NEXT: [[S1_SCALAR:%.*]] = or i64 [[S0_SCALAR]], [[Y:%.*]]
|
||||
; CHECK-NEXT: [[S2_SCALAR:%.*]] = shl i64 [[Z:%.*]], [[S1_SCALAR]]
|
||||
; CHECK-NEXT: [[S2:%.*]] = insertelement <2 x i64> undef, i64 [[S2_SCALAR]], i64 1
|
||||
; CHECK-NEXT: [[S2:%.*]] = insertelement <2 x i64> poison, i64 [[S2_SCALAR]], i64 1
|
||||
; CHECK-NEXT: ret <2 x i64> [[S2]]
|
||||
;
|
||||
%i0 = insertelement <2 x i64> undef, i64 %w, i64 1
|
||||
|
|
Loading…
Reference in New Issue