Skip to content

Commit 8c0a882

Browse files
committed
[AArch64] canCreateUndefOrPoisonForTargetNode - AArch64ISD::MOVI opcodes can't create undef/poison
Possible fix for failed fold in llvm#148191
1 parent ba5f31c commit 8c0a882

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30398,6 +30398,23 @@ bool AArch64TargetLowering::SimplifyDemandedBitsForTargetNode(
3039830398
Op, OriginalDemandedBits, OriginalDemandedElts, Known, TLO, Depth);
3039930399
}
3040030400

30401+
bool AArch64TargetLowering::canCreateUndefOrPoisonForTargetNode(
30402+
SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
30403+
bool PoisonOnly, bool ConsiderFlags, unsigned Depth) const {
30404+
30405+
// TODO: Add more target nodes.
30406+
switch (Op.getOpcode()) {
30407+
case AArch64ISD::MOVI:
30408+
case AArch64ISD::MOVIedit:
30409+
case AArch64ISD::MOVImsl:
30410+
case AArch64ISD::MOVIshift:
30411+
case AArch64ISD::MVNIshift:
30412+
return false;
30413+
}
30414+
return TargetLowering::canCreateUndefOrPoisonForTargetNode(
30415+
Op, DemandedElts, DAG, PoisonOnly, ConsiderFlags, Depth);
30416+
}
30417+
3040130418
bool AArch64TargetLowering::isTargetCanonicalConstantNode(SDValue Op) const {
3040230419
return Op.getOpcode() == AArch64ISD::DUP ||
3040330420
Op.getOpcode() == AArch64ISD::MOVI ||

llvm/lib/Target/AArch64/AArch64ISelLowering.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,12 @@ class AArch64TargetLowering : public TargetLowering {
851851
TargetLoweringOpt &TLO,
852852
unsigned Depth) const override;
853853

854+
bool canCreateUndefOrPoisonForTargetNode(SDValue Op,
855+
const APInt &DemandedElts,
856+
const SelectionDAG &DAG,
857+
bool PoisonOnly, bool ConsiderFlags,
858+
unsigned Depth) const override;
859+
854860
bool isTargetCanonicalConstantNode(SDValue Op) const override;
855861

856862
// With the exception of data-predicate transitions, no instructions are

0 commit comments

Comments
 (0)