Skip to content

Commit 18ab129

Browse files
committed
another patch
1 parent a8cc507 commit 18ab129

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ bool CombinerHelper::matchCombineConcatVectors(
330330
for (const MachineOperand &BuildVecMO : Def->uses())
331331
Ops.push_back(BuildVecMO.getReg());
332332
break;
333+
case TargetOpcode::G_POISON:
333334
case TargetOpcode::G_IMPLICIT_DEF: {
334335
LLT OpType = MRI.getType(Reg);
335336
// Keep one undef value for all the undef operands.
@@ -3127,6 +3128,7 @@ bool CombinerHelper::matchCombineInsertVecElts(
31273128
// If we didn't end in a G_IMPLICIT_DEF and the source is not fully
31283129
// overwritten, bail out.
31293130
return TmpInst->getOpcode() == TargetOpcode::G_IMPLICIT_DEF ||
3131+
TmpInst->getOpcode() == TargetOpcode::G_POISON ||
31303132
all_of(MatchInfo, [](Register Reg) { return !!Reg; });
31313133
}
31323134

@@ -3497,12 +3499,13 @@ bool CombinerHelper::matchUseVectorTruncate(MachineInstr &MI,
34973499
if (I < 2)
34983500
return false;
34993501

3500-
// Check the remaining source elements are only G_IMPLICIT_DEF
3502+
// Check the remaining source elements are only G_IMPLICIT_DEF or G_POISON
35013503
for (; I < NumOperands; ++I) {
35023504
auto SrcMI = MRI.getVRegDef(BuildMI->getSourceReg(I));
35033505
auto SrcMIOpc = SrcMI->getOpcode();
35043506

3505-
if (SrcMIOpc != TargetOpcode::G_IMPLICIT_DEF)
3507+
if (SrcMIOpc != TargetOpcode::G_IMPLICIT_DEF &&
3508+
SrcMIOpc != TargetOpcode::G_POISON)
35063509
return false;
35073510
}
35083511

llvm/lib/Target/AArch64/AArch64Combine.td

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,15 @@ def fullrev: GICombineRule <
140140
(apply [{ applyFullRev(*${root}, MRI); }])
141141
>;
142142

143+
def fullrevpoison: GICombineRule <
144+
(defs root:$root, shuffle_matchdata:$matchinfo),
145+
(match (G_POISON $src2),
146+
(G_SHUFFLE_VECTOR $src, $src1, $src2, $mask):$root,
147+
[{ return ShuffleVectorInst::isReverseMask(${mask}.getShuffleMask(),
148+
${mask}.getShuffleMask().size()); }]),
149+
(apply [{ applyFullRev(*${root}, MRI); }])
150+
>;
151+
143152
def insertelt_nonconst: GICombineRule <
144153
(defs root:$root, shuffle_matchdata:$matchinfo),
145154
(match (wip_match_opcode G_INSERT_VECTOR_ELT):$root,
@@ -173,7 +182,8 @@ def form_duplane : GICombineRule <
173182
>;
174183

175184
def shuffle_vector_lowering : GICombineGroup<[dup, rev, ext, zip, uzp, trn, fullrev,
176-
form_duplane, shuf_to_ins]>;
185+
fullrevpoison, form_duplane,
186+
shuf_to_ins]>;
177187

178188
// Turn G_UNMERGE_VALUES -> G_EXTRACT_VECTOR_ELT's
179189
def vector_unmerge_lowering : GICombineRule <

llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
# DEBUG-NEXT: .. the first uncovered imm index: {{[0-9]+}}, OK
8484
#
8585
# DEBUG-NEXT: G_POISON (opcode {{[0-9]+}}): 1 type index, 0 imm indices
86+
# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to {{[0-9]+}}
8687
# DEBUG-NEXT: .. the first uncovered type index: {{[0-9]+}}, OK
8788
# DEBUG-NEXT: .. the first uncovered imm index: {{[0-9]+}}, OK
8889
#

0 commit comments

Comments
 (0)