Skip to content

Commit 053750c

Browse files
author
Chen Zheng
committed
[PowerPC] Fix the undef register for VECINSERT
If the V2 of the vector_shuffle is undef, the two vector inputs are expected to be the same when do the VECINSERT transformation. For now the first operand of VECINSERT is set to undef which is not right. This patch fixes this bug.
1 parent d7e0ea2 commit 053750c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10142,7 +10142,9 @@ SDValue PPCTargetLowering::LowerVECTOR_SHUFFLE(SDValue Op,
1014210142
if (Subtarget.hasP9Vector() &&
1014310143
PPC::isXXINSERTWMask(SVOp, ShiftElts, InsertAtByte, Swap,
1014410144
isLittleEndian)) {
10145-
if (Swap)
10145+
if (V2.isUndef())
10146+
V2 = V1;
10147+
else if (Swap)
1014610148
std::swap(V1, V2);
1014710149
SDValue Conv1 = DAG.getNode(ISD::BITCAST, dl, MVT::v4i32, V1);
1014810150
SDValue Conv2 = DAG.getNode(ISD::BITCAST, dl, MVT::v4i32, V2);

llvm/test/CodeGen/PowerPC/xxinsertw.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ define <4 x i1> @foo(i1 %c1, i1 %c2, i1 %c3) {
2424
; CHECK-NEXT: [[MTVSRWZ2:%[0-9]+]]:vsfrc = MTVSRWZ killed [[COPY5]]
2525
; CHECK-NEXT: [[SUBREG_TO_REG2:%[0-9]+]]:vsrc = SUBREG_TO_REG 1, killed [[MTVSRWZ2]], %subreg.sub_64
2626
; CHECK-NEXT: [[XXPERM:%[0-9]+]]:vsrc = XXPERM killed [[VMRGOW]], [[SUBREG_TO_REG2]], killed [[LXV]]
27-
; CHECK-NEXT: [[DEF:%[0-9]+]]:vsrc = IMPLICIT_DEF
28-
; CHECK-NEXT: [[XXINSERTW:%[0-9]+]]:vsrc = XXINSERTW [[DEF]], killed [[XXPERM]], 8
27+
; CHECK-NEXT: [[XXINSERTW:%[0-9]+]]:vsrc = XXINSERTW [[XXPERM]], [[XXPERM]], 8
2928
; CHECK-NEXT: $v2 = COPY [[XXINSERTW]]
3029
; CHECK-NEXT: BLR8 implicit $lr8, implicit $rm, implicit $v2
3130
%1 = insertelement <4 x i1> poison, i1 %c1, i64 0

0 commit comments

Comments
 (0)