Skip to content

Commit b155053

Browse files
committed
Plumb through constant folded base vector to avoid x86 regressions
1 parent 20a5d81 commit b155053

File tree

9 files changed

+138
-223
lines changed

9 files changed

+138
-223
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "llvm/ADT/Statistic.h"
2020
#include "llvm/Analysis/AssumptionCache.h"
2121
#include "llvm/Analysis/BasicAliasAnalysis.h"
22+
#include "llvm/Analysis/ConstantFolding.h"
2223
#include "llvm/Analysis/GlobalsModRef.h"
2324
#include "llvm/Analysis/Loads.h"
2425
#include "llvm/Analysis/TargetTransformInfo.h"
@@ -1088,20 +1089,25 @@ bool VectorCombine::scalarizeBinopOrCmp(Instruction &I) {
10881089
VectorOpCost = TTI.getArithmeticInstrCost(Opcode, VecTy, CostKind);
10891090
}
10901091

1092+
// Fold the vector constants in the original vectors into a new base vector.
1093+
Value *NewVecC =
1094+
IsCmp ? ConstantFoldCompareInstOperands(Pred, VecC0, VecC1, *DL)
1095+
: ConstantFoldBinaryOpOperands((Instruction::BinaryOps)Opcode,
1096+
VecC0, VecC1, *DL);
1097+
10911098
// Get cost estimate for the insert element. This cost will factor into
10921099
// both sequences.
1093-
InstructionCost InsertCost = TTI.getVectorInstrCost(
1094-
Instruction::InsertElement, VecTy, CostKind, Index);
1100+
InstructionCost InsertCostNewVecC = TTI.getVectorInstrCost(
1101+
Instruction::InsertElement, VecTy, CostKind, Index, NewVecC);
10951102
InstructionCost InsertCostV0 = TTI.getVectorInstrCost(
10961103
Instruction::InsertElement, VecTy, CostKind, Index, VecC0, V0);
10971104
InstructionCost InsertCostV1 = TTI.getVectorInstrCost(
10981105
Instruction::InsertElement, VecTy, CostKind, Index, VecC1, V1);
10991106
InstructionCost OldCost = (IsConst0 ? 0 : InsertCostV0) +
11001107
(IsConst1 ? 0 : InsertCostV1) + VectorOpCost;
1101-
InstructionCost NewCost = ScalarOpCost + InsertCost +
1108+
InstructionCost NewCost = ScalarOpCost + InsertCostNewVecC +
11021109
(IsConst0 ? 0 : !Ins0->hasOneUse() * InsertCostV0) +
11031110
(IsConst1 ? 0 : !Ins1->hasOneUse() * InsertCostV1);
1104-
11051111
// We want to scalarize unless the vector variant actually has lower cost.
11061112
if (OldCost < NewCost || !NewCost.isValid())
11071113
return false;
@@ -1130,10 +1136,11 @@ bool VectorCombine::scalarizeBinopOrCmp(Instruction &I) {
11301136
if (auto *ScalarInst = dyn_cast<Instruction>(Scalar))
11311137
ScalarInst->copyIRFlags(&I);
11321138

1133-
// Fold the vector constants in the original vectors into a new base vector.
1134-
Value *NewVecC =
1135-
IsCmp ? Builder.CreateCmp(Pred, VecC0, VecC1)
1136-
: Builder.CreateBinOp((Instruction::BinaryOps)Opcode, VecC0, VecC1);
1139+
// Create a new base vector in case the constant folding failed.
1140+
if (!NewVecC)
1141+
NewVecC = IsCmp ? Builder.CreateCmp(Pred, VecC0, VecC1)
1142+
: Builder.CreateBinOp((Instruction::BinaryOps)Opcode, VecC0,
1143+
VecC1);
11371144
Value *Insert = Builder.CreateInsertElement(NewVecC, Scalar, Index);
11381145
replaceValue(I, *Insert);
11391146
return true;

llvm/test/Transforms/PhaseOrdering/X86/scalarization-inseltpoison.ll

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,21 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
1212
define <4 x i32> @square(<4 x i32> %num, i32 %y, i32 %x, i32 %h, i32 %k, i32 %w, i32 %p, i32 %j, i32 %u) {
1313
; CHECK-LABEL: @square(
1414
; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[K:%.*]], 2
15-
; CHECK-NEXT: [[SPLATINSERT:%.*]] = insertelement <4 x i32> poison, i32 [[DIV]], i64 0
1615
; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[P:%.*]], 6234
17-
; CHECK-NEXT: [[SPLATINSERT2:%.*]] = insertelement <4 x i32> poison, i32 [[MUL]], i64 0
1816
; CHECK-NEXT: [[MUL5:%.*]] = mul nsw i32 [[H:%.*]], 75
19-
; CHECK-NEXT: [[SPLATINSERT6:%.*]] = insertelement <4 x i32> poison, i32 [[MUL5]], i64 0
2017
; CHECK-NEXT: [[DIV9:%.*]] = sdiv i32 [[J:%.*]], 3452
21-
; CHECK-NEXT: [[SPLATINSERT10:%.*]] = insertelement <4 x i32> poison, i32 [[DIV9]], i64 0
2218
; CHECK-NEXT: [[MUL13:%.*]] = mul nsw i32 [[W:%.*]], 53
23-
; CHECK-NEXT: [[SPLATINSERT14:%.*]] = insertelement <4 x i32> poison, i32 [[MUL13]], i64 0
2419
; CHECK-NEXT: [[DIV17:%.*]] = sdiv i32 [[X:%.*]], 820
25-
; CHECK-NEXT: [[SPLATINSERT18:%.*]] = insertelement <4 x i32> poison, i32 [[DIV17]], i64 0
2620
; CHECK-NEXT: [[MUL21:%.*]] = shl nsw i32 [[U:%.*]], 2
27-
; CHECK-NEXT: [[SPLATINSERT22:%.*]] = insertelement <4 x i32> poison, i32 [[MUL21]], i64 0
28-
; CHECK-NEXT: [[SPLATINSERT25:%.*]] = insertelement <4 x i32> poison, i32 [[Y:%.*]], i64 0
29-
; CHECK-NEXT: [[TMP9:%.*]] = add <4 x i32> [[SPLATINSERT25]], <i32 1, i32 poison, i32 poison, i32 poison>
30-
; CHECK-NEXT: [[TMP10:%.*]] = add <4 x i32> [[TMP9]], [[SPLATINSERT18]]
31-
; CHECK-NEXT: [[TMP3:%.*]] = add <4 x i32> [[TMP10]], [[SPLATINSERT6]]
32-
; CHECK-NEXT: [[TMP4:%.*]] = add <4 x i32> [[TMP3]], [[SPLATINSERT]]
33-
; CHECK-NEXT: [[TMP5:%.*]] = add <4 x i32> [[TMP4]], [[SPLATINSERT14]]
34-
; CHECK-NEXT: [[TMP6:%.*]] = add <4 x i32> [[TMP5]], [[SPLATINSERT2]]
35-
; CHECK-NEXT: [[TMP7:%.*]] = add <4 x i32> [[TMP6]], [[SPLATINSERT10]]
36-
; CHECK-NEXT: [[TMP8:%.*]] = add <4 x i32> [[TMP7]], [[SPLATINSERT22]]
37-
; CHECK-NEXT: [[TMP1:%.*]] = add <4 x i32> [[TMP8]], <i32 317425, i32 poison, i32 poison, i32 poison>
21+
; CHECK-NEXT: [[OP_RDX:%.*]] = add nsw i32 [[DIV17]], 317426
22+
; CHECK-NEXT: [[OP_RDX9:%.*]] = add nsw i32 [[DIV]], [[DIV9]]
23+
; CHECK-NEXT: [[OP_RDX10:%.*]] = add i32 [[MUL5]], [[MUL13]]
24+
; CHECK-NEXT: [[OP_RDX11:%.*]] = add i32 [[MUL]], [[MUL21]]
25+
; CHECK-NEXT: [[OP_RDX12:%.*]] = add i32 [[OP_RDX]], [[OP_RDX9]]
26+
; CHECK-NEXT: [[OP_RDX13:%.*]] = add i32 [[OP_RDX10]], [[OP_RDX11]]
27+
; CHECK-NEXT: [[OP_RDX14:%.*]] = add i32 [[OP_RDX12]], [[OP_RDX13]]
28+
; CHECK-NEXT: [[OP_RDX15:%.*]] = add i32 [[OP_RDX14]], [[Y:%.*]]
29+
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x i32> poison, i32 [[OP_RDX15]], i64 0
3830
; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <4 x i32> zeroinitializer
3931
; CHECK-NEXT: [[ADD29:%.*]] = add <4 x i32> [[TMP2]], [[NUM:%.*]]
4032
; CHECK-NEXT: ret <4 x i32> [[ADD29]]

llvm/test/Transforms/PhaseOrdering/X86/scalarization.ll

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,21 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
1212
define <4 x i32> @square(<4 x i32> %num, i32 %y, i32 %x, i32 %h, i32 %k, i32 %w, i32 %p, i32 %j, i32 %u) {
1313
; CHECK-LABEL: @square(
1414
; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[K:%.*]], 2
15-
; CHECK-NEXT: [[SPLATINSERT:%.*]] = insertelement <4 x i32> poison, i32 [[DIV]], i64 0
1615
; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[P:%.*]], 6234
17-
; CHECK-NEXT: [[SPLATINSERT2:%.*]] = insertelement <4 x i32> poison, i32 [[MUL]], i64 0
1816
; CHECK-NEXT: [[MUL5:%.*]] = mul nsw i32 [[H:%.*]], 75
19-
; CHECK-NEXT: [[SPLATINSERT6:%.*]] = insertelement <4 x i32> poison, i32 [[MUL5]], i64 0
2017
; CHECK-NEXT: [[DIV9:%.*]] = sdiv i32 [[J:%.*]], 3452
21-
; CHECK-NEXT: [[SPLATINSERT10:%.*]] = insertelement <4 x i32> poison, i32 [[DIV9]], i64 0
2218
; CHECK-NEXT: [[MUL13:%.*]] = mul nsw i32 [[W:%.*]], 53
23-
; CHECK-NEXT: [[SPLATINSERT14:%.*]] = insertelement <4 x i32> poison, i32 [[MUL13]], i64 0
2419
; CHECK-NEXT: [[DIV17:%.*]] = sdiv i32 [[X:%.*]], 820
25-
; CHECK-NEXT: [[SPLATINSERT18:%.*]] = insertelement <4 x i32> poison, i32 [[DIV17]], i64 0
2620
; CHECK-NEXT: [[MUL21:%.*]] = shl nsw i32 [[U:%.*]], 2
27-
; CHECK-NEXT: [[SPLATINSERT22:%.*]] = insertelement <4 x i32> poison, i32 [[MUL21]], i64 0
28-
; CHECK-NEXT: [[SPLATINSERT25:%.*]] = insertelement <4 x i32> poison, i32 [[Y:%.*]], i64 0
29-
; CHECK-NEXT: [[TMP9:%.*]] = add <4 x i32> [[SPLATINSERT25]], <i32 1, i32 poison, i32 poison, i32 poison>
30-
; CHECK-NEXT: [[TMP10:%.*]] = add <4 x i32> [[TMP9]], [[SPLATINSERT18]]
31-
; CHECK-NEXT: [[TMP3:%.*]] = add <4 x i32> [[TMP10]], [[SPLATINSERT6]]
32-
; CHECK-NEXT: [[TMP4:%.*]] = add <4 x i32> [[TMP3]], [[SPLATINSERT]]
33-
; CHECK-NEXT: [[TMP5:%.*]] = add <4 x i32> [[TMP4]], [[SPLATINSERT14]]
34-
; CHECK-NEXT: [[TMP6:%.*]] = add <4 x i32> [[TMP5]], [[SPLATINSERT2]]
35-
; CHECK-NEXT: [[TMP7:%.*]] = add <4 x i32> [[TMP6]], [[SPLATINSERT10]]
36-
; CHECK-NEXT: [[TMP8:%.*]] = add <4 x i32> [[TMP7]], [[SPLATINSERT22]]
37-
; CHECK-NEXT: [[TMP1:%.*]] = add <4 x i32> [[TMP8]], <i32 317425, i32 poison, i32 poison, i32 poison>
21+
; CHECK-NEXT: [[OP_RDX:%.*]] = add nsw i32 [[DIV17]], 317426
22+
; CHECK-NEXT: [[OP_RDX9:%.*]] = add nsw i32 [[DIV]], [[DIV9]]
23+
; CHECK-NEXT: [[OP_RDX10:%.*]] = add i32 [[MUL5]], [[MUL13]]
24+
; CHECK-NEXT: [[OP_RDX11:%.*]] = add i32 [[MUL]], [[MUL21]]
25+
; CHECK-NEXT: [[OP_RDX12:%.*]] = add i32 [[OP_RDX]], [[OP_RDX9]]
26+
; CHECK-NEXT: [[OP_RDX13:%.*]] = add i32 [[OP_RDX10]], [[OP_RDX11]]
27+
; CHECK-NEXT: [[OP_RDX14:%.*]] = add i32 [[OP_RDX12]], [[OP_RDX13]]
28+
; CHECK-NEXT: [[OP_RDX15:%.*]] = add i32 [[OP_RDX14]], [[Y:%.*]]
29+
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x i32> poison, i32 [[OP_RDX15]], i64 0
3830
; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <4 x i32> zeroinitializer
3931
; CHECK-NEXT: [[ADD29:%.*]] = add <4 x i32> [[TMP2]], [[NUM:%.*]]
4032
; CHECK-NEXT: ret <4 x i32> [[ADD29]]

llvm/test/Transforms/VectorCombine/X86/insert-binop-inseltpoison.ll

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,10 @@ declare void @usef(<4 x float>)
88
; Eliminating an insert is profitable.
99

1010
define <16 x i8> @ins0_ins0_add(i8 %x, i8 %y) {
11-
; SSE-LABEL: @ins0_ins0_add(
12-
; SSE-NEXT: [[I0:%.*]] = insertelement <16 x i8> poison, i8 [[X:%.*]], i32 0
13-
; SSE-NEXT: [[I1:%.*]] = insertelement <16 x i8> poison, i8 [[Y:%.*]], i32 0
14-
; SSE-NEXT: [[R:%.*]] = add <16 x i8> [[I0]], [[I1]]
15-
; SSE-NEXT: ret <16 x i8> [[R]]
16-
;
17-
; AVX-LABEL: @ins0_ins0_add(
18-
; AVX-NEXT: [[R_SCALAR:%.*]] = add i8 [[X:%.*]], [[Y:%.*]]
19-
; AVX-NEXT: [[R:%.*]] = insertelement <16 x i8> poison, i8 [[R_SCALAR]], i64 0
20-
; AVX-NEXT: ret <16 x i8> [[R]]
11+
; CHECK-LABEL: @ins0_ins0_add(
12+
; CHECK-NEXT: [[R_SCALAR:%.*]] = add i8 [[X:%.*]], [[Y:%.*]]
13+
; CHECK-NEXT: [[R:%.*]] = insertelement <16 x i8> poison, i8 [[R_SCALAR]], i64 0
14+
; CHECK-NEXT: ret <16 x i8> [[R]]
2115
;
2216
%i0 = insertelement <16 x i8> poison, i8 %x, i32 0
2317
%i1 = insertelement <16 x i8> poison, i8 %y, i32 0
@@ -161,19 +155,12 @@ define <2 x i64> @ins1_ins1_urem(i64 %x, i64 %y) {
161155
; Extra use is accounted for in cost calculation.
162156

163157
define <4 x i32> @ins0_ins0_xor(i32 %x, i32 %y) {
164-
; SSE-LABEL: @ins0_ins0_xor(
165-
; SSE-NEXT: [[I0:%.*]] = insertelement <4 x i32> poison, i32 [[X:%.*]], i32 0
166-
; SSE-NEXT: call void @use(<4 x i32> [[I0]])
167-
; SSE-NEXT: [[I1:%.*]] = insertelement <4 x i32> poison, i32 [[Y:%.*]], i32 0
168-
; SSE-NEXT: [[R:%.*]] = xor <4 x i32> [[I0]], [[I1]]
169-
; SSE-NEXT: ret <4 x i32> [[R]]
170-
;
171-
; AVX-LABEL: @ins0_ins0_xor(
172-
; AVX-NEXT: [[I0:%.*]] = insertelement <4 x i32> poison, i32 [[X:%.*]], i32 0
173-
; AVX-NEXT: call void @use(<4 x i32> [[I0]])
174-
; AVX-NEXT: [[R_SCALAR:%.*]] = xor i32 [[X]], [[Y:%.*]]
175-
; AVX-NEXT: [[R:%.*]] = insertelement <4 x i32> poison, i32 [[R_SCALAR]], i64 0
176-
; AVX-NEXT: ret <4 x i32> [[R]]
158+
; CHECK-LABEL: @ins0_ins0_xor(
159+
; CHECK-NEXT: [[I0:%.*]] = insertelement <4 x i32> poison, i32 [[X:%.*]], i32 0
160+
; CHECK-NEXT: call void @use(<4 x i32> [[I0]])
161+
; CHECK-NEXT: [[R_SCALAR:%.*]] = xor i32 [[X]], [[Y:%.*]]
162+
; CHECK-NEXT: [[R:%.*]] = insertelement <4 x i32> poison, i32 [[R_SCALAR]], i64 0
163+
; CHECK-NEXT: ret <4 x i32> [[R]]
177164
;
178165
%i0 = insertelement <4 x i32> poison, i32 %x, i32 0
179166
call void @use(<4 x i32> %i0)

llvm/test/Transforms/VectorCombine/X86/insert-binop-with-constant-inseltpoison.ll

Lines changed: 24 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,21 @@
33
; RUN: opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=AVX2 | FileCheck %s --check-prefixes=CHECK,AVX
44

55
define <2 x i64> @add_constant(i64 %x) {
6-
; SSE-LABEL: @add_constant(
7-
; SSE-NEXT: [[INS:%.*]] = insertelement <2 x i64> poison, i64 [[X:%.*]], i32 0
8-
; SSE-NEXT: [[BO:%.*]] = add <2 x i64> [[INS]], <i64 42, i64 undef>
9-
; SSE-NEXT: ret <2 x i64> [[BO]]
10-
;
11-
; AVX-LABEL: @add_constant(
12-
; AVX-NEXT: [[BO_SCALAR:%.*]] = add i64 [[X:%.*]], 42
13-
; AVX-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
14-
; AVX-NEXT: ret <2 x i64> [[BO]]
6+
; CHECK-LABEL: @add_constant(
7+
; CHECK-NEXT: [[BO_SCALAR:%.*]] = add i64 [[X:%.*]], 42
8+
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
9+
; CHECK-NEXT: ret <2 x i64> [[BO]]
1510
;
1611
%ins = insertelement <2 x i64> poison, i64 %x, i32 0
1712
%bo = add <2 x i64> %ins, <i64 42, i64 undef>
1813
ret <2 x i64> %bo
1914
}
2015

2116
define <2 x i64> @add_constant_not_undef_lane(i64 %x) {
22-
; SSE-LABEL: @add_constant_not_undef_lane(
23-
; SSE-NEXT: [[INS:%.*]] = insertelement <2 x i64> poison, i64 [[X:%.*]], i32 0
24-
; SSE-NEXT: [[BO:%.*]] = add <2 x i64> [[INS]], <i64 42, i64 -42>
25-
; SSE-NEXT: ret <2 x i64> [[BO]]
26-
;
27-
; AVX-LABEL: @add_constant_not_undef_lane(
28-
; AVX-NEXT: [[BO_SCALAR:%.*]] = add i64 [[X:%.*]], 42
29-
; AVX-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
30-
; AVX-NEXT: ret <2 x i64> [[BO]]
17+
; CHECK-LABEL: @add_constant_not_undef_lane(
18+
; CHECK-NEXT: [[BO_SCALAR:%.*]] = add i64 [[X:%.*]], 42
19+
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
20+
; CHECK-NEXT: ret <2 x i64> [[BO]]
3121
;
3222
%ins = insertelement <2 x i64> poison, i64 %x, i32 0
3323
%bo = add <2 x i64> %ins, <i64 42, i64 -42>
@@ -489,31 +479,21 @@ define <2 x i64> @sdiv_constant_op1_not_undef_lane(i64 %x) {
489479
}
490480

491481
define <2 x i64> @and_constant(i64 %x) {
492-
; SSE-LABEL: @and_constant(
493-
; SSE-NEXT: [[INS:%.*]] = insertelement <2 x i64> poison, i64 [[X:%.*]], i32 0
494-
; SSE-NEXT: [[BO:%.*]] = and <2 x i64> [[INS]], <i64 42, i64 undef>
495-
; SSE-NEXT: ret <2 x i64> [[BO]]
496-
;
497-
; AVX-LABEL: @and_constant(
498-
; AVX-NEXT: [[BO_SCALAR:%.*]] = and i64 [[X:%.*]], 42
499-
; AVX-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
500-
; AVX-NEXT: ret <2 x i64> [[BO]]
482+
; CHECK-LABEL: @and_constant(
483+
; CHECK-NEXT: [[BO_SCALAR:%.*]] = and i64 [[X:%.*]], 42
484+
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
485+
; CHECK-NEXT: ret <2 x i64> [[BO]]
501486
;
502487
%ins = insertelement <2 x i64> poison, i64 %x, i32 0
503488
%bo = and <2 x i64> %ins, <i64 42, i64 undef>
504489
ret <2 x i64> %bo
505490
}
506491

507492
define <2 x i64> @and_constant_not_undef_lane(i64 %x) {
508-
; SSE-LABEL: @and_constant_not_undef_lane(
509-
; SSE-NEXT: [[INS:%.*]] = insertelement <2 x i64> poison, i64 [[X:%.*]], i32 0
510-
; SSE-NEXT: [[BO:%.*]] = and <2 x i64> [[INS]], <i64 42, i64 -42>
511-
; SSE-NEXT: ret <2 x i64> [[BO]]
512-
;
513-
; AVX-LABEL: @and_constant_not_undef_lane(
514-
; AVX-NEXT: [[BO_SCALAR:%.*]] = and i64 [[X:%.*]], 42
515-
; AVX-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
516-
; AVX-NEXT: ret <2 x i64> [[BO]]
493+
; CHECK-LABEL: @and_constant_not_undef_lane(
494+
; CHECK-NEXT: [[BO_SCALAR:%.*]] = and i64 [[X:%.*]], 42
495+
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
496+
; CHECK-NEXT: ret <2 x i64> [[BO]]
517497
;
518498
%ins = insertelement <2 x i64> poison, i64 %x, i32 0
519499
%bo = and <2 x i64> %ins, <i64 42, i64 -42>
@@ -543,31 +523,21 @@ define <2 x i64> @or_constant_not_undef_lane(i64 %x) {
543523
}
544524

545525
define <2 x i64> @xor_constant(i64 %x) {
546-
; SSE-LABEL: @xor_constant(
547-
; SSE-NEXT: [[INS:%.*]] = insertelement <2 x i64> poison, i64 [[X:%.*]], i32 0
548-
; SSE-NEXT: [[BO:%.*]] = xor <2 x i64> [[INS]], <i64 42, i64 undef>
549-
; SSE-NEXT: ret <2 x i64> [[BO]]
550-
;
551-
; AVX-LABEL: @xor_constant(
552-
; AVX-NEXT: [[BO_SCALAR:%.*]] = xor i64 [[X:%.*]], 42
553-
; AVX-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
554-
; AVX-NEXT: ret <2 x i64> [[BO]]
526+
; CHECK-LABEL: @xor_constant(
527+
; CHECK-NEXT: [[BO_SCALAR:%.*]] = xor i64 [[X:%.*]], 42
528+
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
529+
; CHECK-NEXT: ret <2 x i64> [[BO]]
555530
;
556531
%ins = insertelement <2 x i64> poison, i64 %x, i32 0
557532
%bo = xor <2 x i64> %ins, <i64 42, i64 undef>
558533
ret <2 x i64> %bo
559534
}
560535

561536
define <2 x i64> @xor_constant_not_undef_lane(i64 %x) {
562-
; SSE-LABEL: @xor_constant_not_undef_lane(
563-
; SSE-NEXT: [[INS:%.*]] = insertelement <2 x i64> poison, i64 [[X:%.*]], i32 0
564-
; SSE-NEXT: [[BO:%.*]] = xor <2 x i64> [[INS]], <i64 42, i64 -42>
565-
; SSE-NEXT: ret <2 x i64> [[BO]]
566-
;
567-
; AVX-LABEL: @xor_constant_not_undef_lane(
568-
; AVX-NEXT: [[BO_SCALAR:%.*]] = xor i64 [[X:%.*]], 42
569-
; AVX-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
570-
; AVX-NEXT: ret <2 x i64> [[BO]]
537+
; CHECK-LABEL: @xor_constant_not_undef_lane(
538+
; CHECK-NEXT: [[BO_SCALAR:%.*]] = xor i64 [[X:%.*]], 42
539+
; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
540+
; CHECK-NEXT: ret <2 x i64> [[BO]]
571541
;
572542
%ins = insertelement <2 x i64> poison, i64 %x, i32 0
573543
%bo = xor <2 x i64> %ins, <i64 42, i64 -42>

0 commit comments

Comments
 (0)