Skip to content

Commit 1074b94

Browse files
authored
[ARM] Fix phi operand order issue in MVEGatherScatterLowering (#78208)
With commuted operands on the phi node, the two old incoming values could be removed in the wrong order, removing newly added operand instead of the old one.
1 parent 8e9e4f8 commit 1074b94

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,8 +898,8 @@ void MVEGatherScatterLowering::pushOutAdd(PHINode *&Phi,
898898
Phi->addIncoming(NewIndex, Phi->getIncomingBlock(StartIndex));
899899
Phi->addIncoming(Phi->getIncomingValue(IncrementIndex),
900900
Phi->getIncomingBlock(IncrementIndex));
901-
Phi->removeIncomingValue(IncrementIndex);
902-
Phi->removeIncomingValue(StartIndex);
901+
Phi->removeIncomingValue(1);
902+
Phi->removeIncomingValue((unsigned)0);
903903
}
904904

905905
void MVEGatherScatterLowering::pushOutMulShl(unsigned Opcode, PHINode *&Phi,

llvm/test/CodeGen/Thumb2/mve-gather-optimisation-deep.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ end:
6262
ret void;
6363
}
6464

65-
define arm_aapcs_vfpcc void @push_out_add_sub_block_c(i32* noalias nocapture readonly %data, i32* noalias nocapture %dst, i32 %n.vec) {
66-
; CHECK-LABEL: @push_out_add_sub_block_c(
65+
define arm_aapcs_vfpcc void @push_out_add_sub_block_commutedphi(i32* noalias nocapture readonly %data, i32* noalias nocapture %dst, i32 %n.vec) {
66+
; CHECK-LABEL: @push_out_add_sub_block_commutedphi(
6767
; CHECK-NEXT: vector.ph:
6868
; CHECK-NEXT: [[PUSHEDOUTADD:%.*]] = add <4 x i32> <i32 0, i32 2, i32 4, i32 6>, <i32 6, i32 6, i32 6, i32 6>
69-
; CHECK-NEXT: [[SCALEDINDEX:%.*]] = shl <4 x i32> <i32 0, i32 2, i32 4, i32 6>, <i32 2, i32 2, i32 2, i32 2>
69+
; CHECK-NEXT: [[SCALEDINDEX:%.*]] = shl <4 x i32> [[PUSHEDOUTADD]], <i32 2, i32 2, i32 2, i32 2>
7070
; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[DATA:%.*]] to i32
7171
; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <4 x i32> poison, i32 [[TMP0]], i64 0
7272
; CHECK-NEXT: [[DOTSPLAT:%.*]] = shufflevector <4 x i32> [[DOTSPLATINSERT]], <4 x i32> poison, <4 x i32> zeroinitializer

0 commit comments

Comments
 (0)