[llvm] [DAG] Use UndefPoisonKind enum in isGuaranteedNotToBeUndefOrPoison/canCreateUndefOrPoison/getFreeze (PR #196145)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed May 6 14:51:43 PDT 2026
https://github.com/RKSimon updated https://github.com/llvm/llvm-project/pull/196145
>From 06f65dff459484b5b40b6135aed7b3756d9b425b Mon Sep 17 00:00:00 2001
From: Simon Pilgrim <llvm-dev at redking.me.uk>
Date: Wed, 6 May 2026 19:38:56 +0100
Subject: [PATCH 1/2] [DAG] Use UndefPoisonKind enum in
isGuaranteedNotToBeUndefOrPoison/canCreateUndefOrPoison
Replace the PoisonOnly flag and allow discrimination between undef/poison values - to more closely match ValueTracking / GISel implementations.
This patch is mainly a drop in replacement for the PoisonOnly logic, and hasn't added anything to match UndefOnly logic (e.g. for SelfMultiply patterns) - we can improve upon this later on with proper test coverage.
Fixes #194818
---
llvm/include/llvm/CodeGen/SelectionDAG.h | 41 +++++----
llvm/include/llvm/CodeGen/TargetLowering.h | 13 ++-
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 7 +-
.../lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 86 ++++++++++---------
.../CodeGen/SelectionDAG/TargetLowering.cpp | 14 ++-
.../Target/AArch64/AArch64ISelLowering.cpp | 4 +-
llvm/lib/Target/AArch64/AArch64ISelLowering.h | 8 +-
llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp | 7 +-
llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h | 8 +-
llvm/lib/Target/ARM/ARMISelLowering.cpp | 4 +-
llvm/lib/Target/ARM/ARMISelLowering.h | 9 +-
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 4 +-
llvm/lib/Target/RISCV/RISCVISelLowering.h | 8 +-
.../Target/SystemZ/SystemZISelLowering.cpp | 7 +-
llvm/lib/Target/SystemZ/SystemZISelLowering.h | 2 +-
llvm/lib/Target/X86/X86ISelLowering.cpp | 18 ++--
llvm/lib/Target/X86/X86ISelLowering.h | 11 ++-
17 files changed, 127 insertions(+), 124 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h
index 2512bce02dbeb..9a237821ac378 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAG.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -42,6 +42,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/KnownFPClass.h"
#include "llvm/Support/RecyclingAllocator.h"
+#include "llvm/Support/UndefPoison.h"
#include <cassert>
#include <cstdint>
#include <functional>
@@ -2346,22 +2347,23 @@ class SelectionDAG {
unsigned Depth = 0) const;
/// Return true if this function can prove that \p Op is never poison
- /// and, if \p PoisonOnly is false, does not have undef bits.
- LLVM_ABI bool isGuaranteedNotToBeUndefOrPoison(SDValue Op,
- bool PoisonOnly = false,
- unsigned Depth = 0) const;
+ /// and, \p Kind can be used to track poison and/or undef bits.
+ LLVM_ABI bool isGuaranteedNotToBeUndefOrPoison(
+ SDValue Op, UndefPoisonKind Kind = UndefPoisonKind::UndefOrPoison,
+ unsigned Depth = 0) const;
/// Return true if this function can prove that \p Op is never poison
- /// and, if \p PoisonOnly is false, does not have undef bits. The DemandedElts
- /// argument limits the check to the requested vector elements.
- LLVM_ABI bool isGuaranteedNotToBeUndefOrPoison(SDValue Op,
- const APInt &DemandedElts,
- bool PoisonOnly = false,
- unsigned Depth = 0) const;
+ /// and, \p Kind can be used to track poison and/or undef bits. The
+ /// DemandedElts argument limits the check to the requested vector elements.
+ LLVM_ABI bool isGuaranteedNotToBeUndefOrPoison(
+ SDValue Op, const APInt &DemandedElts,
+ UndefPoisonKind Kind = UndefPoisonKind::UndefOrPoison,
+ unsigned Depth = 0) const;
/// Return true if this function can prove that \p Op is never poison.
bool isGuaranteedNotToBePoison(SDValue Op, unsigned Depth = 0) const {
- return isGuaranteedNotToBeUndefOrPoison(Op, /*PoisonOnly*/ true, Depth);
+ return isGuaranteedNotToBeUndefOrPoison(Op, UndefPoisonKind::PoisonOnly,
+ Depth);
}
/// Return true if this function can prove that \p Op is never poison. The
@@ -2369,7 +2371,7 @@ class SelectionDAG {
bool isGuaranteedNotToBePoison(SDValue Op, const APInt &DemandedElts,
unsigned Depth = 0) const {
return isGuaranteedNotToBeUndefOrPoison(Op, DemandedElts,
- /*PoisonOnly*/ true, Depth);
+ UndefPoisonKind::PoisonOnly, Depth);
}
/// Return true if Op can create undef or poison from non-undef & non-poison
@@ -2381,10 +2383,10 @@ class SelectionDAG {
/// could still introduce undef or poison even without poison generating flags
/// which might be on the instruction. (i.e. could the result of
/// Op->dropPoisonGeneratingFlags() still create poison or undef)
- LLVM_ABI bool canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
- bool PoisonOnly = false,
- bool ConsiderFlags = true,
- unsigned Depth = 0) const;
+ LLVM_ABI bool
+ canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
+ UndefPoisonKind Kind = UndefPoisonKind::UndefOrPoison,
+ bool ConsiderFlags = true, unsigned Depth = 0) const;
/// Return true if Op can create undef or poison from non-undef & non-poison
/// operands.
@@ -2394,9 +2396,10 @@ class SelectionDAG {
/// could still introduce undef or poison even without poison generating flags
/// which might be on the instruction. (i.e. could the result of
/// Op->dropPoisonGeneratingFlags() still create poison or undef)
- LLVM_ABI bool canCreateUndefOrPoison(SDValue Op, bool PoisonOnly = false,
- bool ConsiderFlags = true,
- unsigned Depth = 0) const;
+ LLVM_ABI bool
+ canCreateUndefOrPoison(SDValue Op,
+ UndefPoisonKind Kind = UndefPoisonKind::UndefOrPoison,
+ bool ConsiderFlags = true, unsigned Depth = 0) const;
/// Return true if the specified operand is an ISD::OR or ISD::XOR node
/// that can be treated as an ISD::ADD node.
diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h
index 9b0bfa111f2d5..fb97efa16800b 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -4467,19 +4467,18 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
SelectionDAG &DAG, unsigned Depth) const;
/// Return true if this function can prove that \p Op is never poison
- /// and, if \p PoisonOnly is false, does not have undef bits. The DemandedElts
- /// argument limits the check to the requested vector elements.
+ /// and, \p Kind can be used to track poison and/or undef bits. The
+ /// DemandedElts argument limits the check to the requested vector elements.
virtual bool isGuaranteedNotToBeUndefOrPoisonForTargetNode(
SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
- bool PoisonOnly, unsigned Depth) const;
+ UndefPoisonKind Kind, unsigned Depth) const;
/// Return true if Op can create undef or poison from non-undef & non-poison
/// operands. The DemandedElts argument limits the check to the requested
/// vector elements.
- virtual bool
- canCreateUndefOrPoisonForTargetNode(SDValue Op, const APInt &DemandedElts,
- const SelectionDAG &DAG, bool PoisonOnly,
- bool ConsiderFlags, unsigned Depth) const;
+ virtual bool canCreateUndefOrPoisonForTargetNode(
+ SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
+ UndefPoisonKind Kind, bool ConsiderFlags, unsigned Depth) const;
/// Tries to build a legal vector shuffle using the provided parameters
/// or equivalent variations. The Mask argument maybe be modified as the
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 2debe9bacf40f..6ddfbe1755fad 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -17869,7 +17869,7 @@ SDValue DAGCombiner::visitBUILD_PAIR(SDNode *N) {
SDValue DAGCombiner::visitFREEZE(SDNode *N) {
SDValue N0 = N->getOperand(0);
- if (DAG.isGuaranteedNotToBeUndefOrPoison(N0, /*PoisonOnly*/ false))
+ if (DAG.isGuaranteedNotToBeUndefOrPoison(N0, UndefPoisonKind::UndefOrPoison))
return N0;
// If we have frozen and unfrozen users of N0, update so everything uses N.
@@ -17900,7 +17900,7 @@ SDValue DAGCombiner::visitFREEZE(SDNode *N) {
// guaranteed-non-poison operands (or is a BUILD_VECTOR or similar) then push
// the freeze through to the operands that are not guaranteed non-poison.
// NOTE: we will strip poison-generating flags, so ignore them here.
- if (DAG.canCreateUndefOrPoison(N0, /*PoisonOnly*/ false,
+ if (DAG.canCreateUndefOrPoison(N0, UndefPoisonKind::UndefOrPoison,
/*ConsiderFlags*/ false) ||
N0->getNumValues() != 1 || !N0->hasOneUse())
return SDValue();
@@ -17941,7 +17941,8 @@ SDValue DAGCombiner::visitFREEZE(SDNode *N) {
SmallSet<SDValue, 8> MaybePoisonOperands;
SmallVector<unsigned, 8> MaybePoisonOperandNumbers;
for (auto [OpNo, Op] : enumerate(N0->ops())) {
- if (DAG.isGuaranteedNotToBeUndefOrPoison(Op, /*PoisonOnly=*/false))
+ if (DAG.isGuaranteedNotToBeUndefOrPoison(Op,
+ UndefPoisonKind::UndefOrPoison))
continue;
bool HadMaybePoisonOperands = !MaybePoisonOperands.empty();
bool IsNewMaybePoisonOperand = MaybePoisonOperands.insert(Op).second;
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 857ff98f84b32..95c3dc4c3d88a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -2571,7 +2571,9 @@ SDValue SelectionDAG::getFreeze(SDValue V) {
SDValue SelectionDAG::getFreeze(SDValue V, const APInt &DemandedElts,
bool PoisonOnly) {
- if (isGuaranteedNotToBeUndefOrPoison(V, DemandedElts, PoisonOnly))
+ UndefPoisonKind Kind =
+ PoisonOnly ? UndefPoisonKind::PoisonOnly : UndefPoisonKind::UndefOrPoison;
+ if (isGuaranteedNotToBeUndefOrPoison(V, DemandedElts, Kind))
return V;
return getFreeze(V);
}
@@ -3669,7 +3671,8 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
// TODO: SelfMultiply can be poison, but not undef.
if (SelfMultiply)
SelfMultiply &= isGuaranteedNotToBeUndefOrPoison(
- Op.getOperand(0), DemandedElts, false, Depth + 1);
+ Op.getOperand(0), DemandedElts, UndefPoisonKind::UndefOrPoison,
+ Depth + 1);
Known = KnownBits::mul(Known, Known2, SelfMultiply);
// If the multiplication is known not to overflow, the product of a number
@@ -4158,7 +4161,8 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
Known2 = computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1);
bool SelfAdd = Op.getOperand(0) == Op.getOperand(1) &&
isGuaranteedNotToBeUndefOrPoison(
- Op.getOperand(0), DemandedElts, false, Depth + 1);
+ Op.getOperand(0), DemandedElts,
+ UndefPoisonKind::UndefOrPoison, Depth + 1);
Known = KnownBits::add(Known, Known2, Flags.hasNoSignedWrap(),
Flags.hasNoUnsignedWrap(), SelfAdd);
break;
@@ -4935,7 +4939,7 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
return VTBits-Tmp;
case ISD::FREEZE:
if (isGuaranteedNotToBeUndefOrPoison(Op.getOperand(0), DemandedElts,
- /*PoisonOnly=*/false))
+ UndefPoisonKind::UndefOrPoison))
return ComputeNumSignBits(Op.getOperand(0), DemandedElts, Depth + 1);
break;
case ISD::MERGE_VALUES:
@@ -5609,19 +5613,20 @@ unsigned SelectionDAG::ComputeMaxSignificantBits(SDValue Op,
return Op.getScalarValueSizeInBits() - SignBits + 1;
}
-bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op, bool PoisonOnly,
+bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
+ UndefPoisonKind Kind,
unsigned Depth) const {
// Early out for FREEZE.
if (Op.getOpcode() == ISD::FREEZE)
return true;
APInt DemandedElts = getDemandAllEltsMask(Op);
- return isGuaranteedNotToBeUndefOrPoison(Op, DemandedElts, PoisonOnly, Depth);
+ return isGuaranteedNotToBeUndefOrPoison(Op, DemandedElts, Kind, Depth);
}
bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
const APInt &DemandedElts,
- bool PoisonOnly,
+ UndefPoisonKind Kind,
unsigned Depth) const {
unsigned Opcode = Op.getOpcode();
@@ -5644,10 +5649,10 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
return true;
case ISD::POISON:
- return false;
+ return !includesPoison(Kind);
case ISD::UNDEF:
- return PoisonOnly;
+ return !includesUndef(Kind);
case ISD::BUILD_VECTOR:
// NOTE: BUILD_VECTOR has implicit truncation of wider scalar elements -
@@ -5655,8 +5660,7 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
for (unsigned i = 0, e = Op.getNumOperands(); i < e; ++i) {
if (!DemandedElts[i])
continue;
- if (!isGuaranteedNotToBeUndefOrPoison(Op.getOperand(i), PoisonOnly,
- Depth + 1))
+ if (!isGuaranteedNotToBeUndefOrPoison(Op.getOperand(i), Kind, Depth + 1))
return false;
}
return true;
@@ -5668,7 +5672,7 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
uint64_t Idx = Op.getConstantOperandVal(1);
unsigned NumSrcElts = Src.getValueType().getVectorNumElements();
APInt DemandedSrcElts = DemandedElts.zext(NumSrcElts).shl(Idx);
- return isGuaranteedNotToBeUndefOrPoison(Src, DemandedSrcElts, PoisonOnly,
+ return isGuaranteedNotToBeUndefOrPoison(Src, DemandedSrcElts, Kind,
Depth + 1);
}
@@ -5684,10 +5688,10 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
DemandedSrcElts.clearBits(Idx, Idx + NumSubElts);
if (!!DemandedSubElts && !isGuaranteedNotToBeUndefOrPoison(
- Sub, DemandedSubElts, PoisonOnly, Depth + 1))
+ Sub, DemandedSubElts, Kind, Depth + 1))
return false;
if (!!DemandedSrcElts && !isGuaranteedNotToBeUndefOrPoison(
- Src, DemandedSrcElts, PoisonOnly, Depth + 1))
+ Src, DemandedSrcElts, Kind, Depth + 1))
return false;
return true;
}
@@ -5700,7 +5704,7 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
IndexC->getAPIntValue().ult(SrcVT.getVectorNumElements())) {
APInt DemandedSrcElts = APInt::getOneBitSet(SrcVT.getVectorNumElements(),
IndexC->getZExtValue());
- return isGuaranteedNotToBeUndefOrPoison(Src, DemandedSrcElts, PoisonOnly,
+ return isGuaranteedNotToBeUndefOrPoison(Src, DemandedSrcElts, Kind,
Depth + 1);
}
break;
@@ -5715,14 +5719,14 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
if (IndexC && VT.isFixedLengthVector() &&
IndexC->getAPIntValue().ult(VT.getVectorNumElements())) {
if (DemandedElts[IndexC->getZExtValue()] &&
- !isGuaranteedNotToBeUndefOrPoison(InVal, PoisonOnly, Depth + 1))
+ !isGuaranteedNotToBeUndefOrPoison(InVal, Kind, Depth + 1))
return false;
APInt InVecDemandedElts = DemandedElts;
InVecDemandedElts.clearBit(IndexC->getZExtValue());
if (!!InVecDemandedElts &&
!isGuaranteedNotToBeUndefOrPoison(
peekThroughInsertVectorElt(InVec, InVecDemandedElts),
- InVecDemandedElts, PoisonOnly, Depth + 1))
+ InVecDemandedElts, Kind, Depth + 1))
return false;
return true;
}
@@ -5731,17 +5735,16 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
case ISD::SCALAR_TO_VECTOR:
// Check upper (known undef) elements.
- if (DemandedElts.ugt(1) && !PoisonOnly)
+ if (DemandedElts.ugt(1) && includesUndef(Kind))
return false;
// Check element zero.
- if (DemandedElts[0] && !isGuaranteedNotToBeUndefOrPoison(
- Op.getOperand(0), PoisonOnly, Depth + 1))
+ if (DemandedElts[0] &&
+ !isGuaranteedNotToBeUndefOrPoison(Op.getOperand(0), Kind, Depth + 1))
return false;
return true;
case ISD::SPLAT_VECTOR:
- return isGuaranteedNotToBeUndefOrPoison(Op.getOperand(0), PoisonOnly,
- Depth + 1);
+ return isGuaranteedNotToBeUndefOrPoison(Op.getOperand(0), Kind, Depth + 1);
case ISD::VECTOR_SHUFFLE: {
APInt DemandedLHS, DemandedRHS;
@@ -5751,12 +5754,12 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
/*AllowUndefElts=*/false))
return false;
if (!DemandedLHS.isZero() &&
- !isGuaranteedNotToBeUndefOrPoison(Op.getOperand(0), DemandedLHS,
- PoisonOnly, Depth + 1))
+ !isGuaranteedNotToBeUndefOrPoison(Op.getOperand(0), DemandedLHS, Kind,
+ Depth + 1))
return false;
if (!DemandedRHS.isZero() &&
- !isGuaranteedNotToBeUndefOrPoison(Op.getOperand(1), DemandedRHS,
- PoisonOnly, Depth + 1))
+ !isGuaranteedNotToBeUndefOrPoison(Op.getOperand(1), DemandedRHS, Kind,
+ Depth + 1))
return false;
return true;
}
@@ -5766,10 +5769,10 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
case ISD::SRA:
// Shift amount operand is checked by canCreateUndefOrPoison. So it is
// enough to check operand 0 if Op can't create undef/poison.
- return !canCreateUndefOrPoison(Op, DemandedElts, PoisonOnly,
+ return !canCreateUndefOrPoison(Op, DemandedElts, Kind,
/*ConsiderFlags*/ true, Depth) &&
isGuaranteedNotToBeUndefOrPoison(Op.getOperand(0), DemandedElts,
- PoisonOnly, Depth + 1);
+ Kind, Depth + 1);
case ISD::BSWAP:
case ISD::CTPOP:
@@ -5799,11 +5802,11 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
// then Op is never undef/poison. A difference from the more common check
// below, outside the switch, is that we handle elementwise operations for
// which the DemandedElts mask is valid for all operands here.
- return !canCreateUndefOrPoison(Op, DemandedElts, PoisonOnly,
+ return !canCreateUndefOrPoison(Op, DemandedElts, Kind,
/*ConsiderFlags*/ true, Depth) &&
all_of(Op->ops(), [&](SDValue V) {
- return isGuaranteedNotToBeUndefOrPoison(V, DemandedElts,
- PoisonOnly, Depth + 1);
+ return isGuaranteedNotToBeUndefOrPoison(V, DemandedElts, Kind,
+ Depth + 1);
});
}
@@ -5816,7 +5819,7 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
if (Opcode >= ISD::BUILTIN_OP_END || Opcode == ISD::INTRINSIC_WO_CHAIN ||
Opcode == ISD::INTRINSIC_W_CHAIN || Opcode == ISD::INTRINSIC_VOID)
return TLI->isGuaranteedNotToBeUndefOrPoisonForTargetNode(
- Op, DemandedElts, *this, PoisonOnly, Depth);
+ Op, DemandedElts, *this, Kind, Depth);
break;
}
@@ -5825,23 +5828,22 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
// NOTE: TargetNodes can handle this in themselves in
// isGuaranteedNotToBeUndefOrPoisonForTargetNode or let
// TargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode handle it.
- return !canCreateUndefOrPoison(Op, PoisonOnly, /*ConsiderFlags*/ true,
- Depth) &&
+ return !canCreateUndefOrPoison(Op, Kind, /*ConsiderFlags*/ true, Depth) &&
all_of(Op->ops(), [&](SDValue V) {
- return isGuaranteedNotToBeUndefOrPoison(V, PoisonOnly, Depth + 1);
+ return isGuaranteedNotToBeUndefOrPoison(V, Kind, Depth + 1);
});
}
-bool SelectionDAG::canCreateUndefOrPoison(SDValue Op, bool PoisonOnly,
+bool SelectionDAG::canCreateUndefOrPoison(SDValue Op, UndefPoisonKind Kind,
bool ConsiderFlags,
unsigned Depth) const {
APInt DemandedElts = getDemandAllEltsMask(Op);
- return canCreateUndefOrPoison(Op, DemandedElts, PoisonOnly, ConsiderFlags,
- Depth);
+ return canCreateUndefOrPoison(Op, DemandedElts, Kind, ConsiderFlags, Depth);
}
bool SelectionDAG::canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
- bool PoisonOnly, bool ConsiderFlags,
+ UndefPoisonKind Kind,
+ bool ConsiderFlags,
unsigned Depth) const {
if (ConsiderFlags && Op->hasPoisonGeneratingFlags())
return true;
@@ -5980,7 +5982,7 @@ bool SelectionDAG::canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
case ISD::SCALAR_TO_VECTOR:
// Check if we demand any upper (undef) elements.
- return !PoisonOnly && DemandedElts.ugt(1);
+ return includesUndef(Kind) && DemandedElts.ugt(1);
case ISD::INSERT_VECTOR_ELT:
case ISD::EXTRACT_VECTOR_ELT: {
@@ -6008,7 +6010,7 @@ bool SelectionDAG::canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
if (Opcode >= ISD::BUILTIN_OP_END || Opcode == ISD::INTRINSIC_WO_CHAIN ||
Opcode == ISD::INTRINSIC_W_CHAIN || Opcode == ISD::INTRINSIC_VOID)
return TLI->canCreateUndefOrPoisonForTargetNode(
- Op, DemandedElts, *this, PoisonOnly, ConsiderFlags, Depth);
+ Op, DemandedElts, *this, Kind, ConsiderFlags, Depth);
break;
}
@@ -7029,7 +7031,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
break;
case ISD::FREEZE:
assert(VT == N1.getValueType() && "Unexpected VT!");
- if (isGuaranteedNotToBeUndefOrPoison(N1, /*PoisonOnly=*/false))
+ if (isGuaranteedNotToBeUndefOrPoison(N1, UndefPoisonKind::UndefOrPoison))
return N1;
break;
case ISD::TokenFactor:
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 867fd87d3c137..54633a84dffca 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -3374,9 +3374,8 @@ bool TargetLowering::SimplifyDemandedVectorElts(
}
case ISD::FREEZE: {
SDValue N0 = Op.getOperand(0);
- if (TLO.DAG.isGuaranteedNotToBeUndefOrPoison(N0, DemandedElts,
- /*PoisonOnly=*/false,
- Depth + 1))
+ if (TLO.DAG.isGuaranteedNotToBeUndefOrPoison(
+ N0, DemandedElts, UndefPoisonKind::UndefOrPoison, Depth + 1))
return TLO.CombineTo(Op, N0);
// TODO: Replace this with the general fold from DAGCombiner::visitFREEZE
@@ -4033,7 +4032,7 @@ const Constant *TargetLowering::getTargetConstantFromLoad(LoadSDNode*) const {
bool TargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode(
SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
- bool PoisonOnly, unsigned Depth) const {
+ UndefPoisonKind Kind, unsigned Depth) const {
assert(
(Op.getOpcode() >= ISD::BUILTIN_OP_END ||
Op.getOpcode() == ISD::INTRINSIC_WO_CHAIN ||
@@ -4044,17 +4043,16 @@ bool TargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode(
// If Op can't create undef/poison and none of its operands are undef/poison
// then Op is never undef/poison.
- return !canCreateUndefOrPoisonForTargetNode(Op, DemandedElts, DAG, PoisonOnly,
+ return !canCreateUndefOrPoisonForTargetNode(Op, DemandedElts, DAG, Kind,
/*ConsiderFlags*/ true, Depth) &&
all_of(Op->ops(), [&](SDValue V) {
- return DAG.isGuaranteedNotToBeUndefOrPoison(V, PoisonOnly,
- Depth + 1);
+ return DAG.isGuaranteedNotToBeUndefOrPoison(V, Kind, Depth + 1);
});
}
bool TargetLowering::canCreateUndefOrPoisonForTargetNode(
SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
- bool PoisonOnly, bool ConsiderFlags, unsigned Depth) const {
+ UndefPoisonKind Kind, bool ConsiderFlags, unsigned Depth) const {
assert((Op.getOpcode() >= ISD::BUILTIN_OP_END ||
Op.getOpcode() == ISD::INTRINSIC_WO_CHAIN ||
Op.getOpcode() == ISD::INTRINSIC_W_CHAIN ||
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 8c53ea0dd94eb..6efc377617006 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -33335,7 +33335,7 @@ bool AArch64TargetLowering::SimplifyDemandedBitsForTargetNode(
bool AArch64TargetLowering::canCreateUndefOrPoisonForTargetNode(
SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
- bool PoisonOnly, bool ConsiderFlags, unsigned Depth) const {
+ UndefPoisonKind Kind, bool ConsiderFlags, unsigned Depth) const {
// TODO: Add more target nodes.
switch (Op.getOpcode()) {
@@ -33351,7 +33351,7 @@ bool AArch64TargetLowering::canCreateUndefOrPoisonForTargetNode(
return false;
}
return TargetLowering::canCreateUndefOrPoisonForTargetNode(
- Op, DemandedElts, DAG, PoisonOnly, ConsiderFlags, Depth);
+ Op, DemandedElts, DAG, Kind, ConsiderFlags, Depth);
}
bool AArch64TargetLowering::isTargetCanonicalConstantNode(SDValue Op) const {
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.h b/llvm/lib/Target/AArch64/AArch64ISelLowering.h
index 80d49bb2ed318..2e66b5ad896ef 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.h
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.h
@@ -906,11 +906,9 @@ class AArch64TargetLowering : public TargetLowering {
TargetLoweringOpt &TLO,
unsigned Depth) const override;
- bool canCreateUndefOrPoisonForTargetNode(SDValue Op,
- const APInt &DemandedElts,
- const SelectionDAG &DAG,
- bool PoisonOnly, bool ConsiderFlags,
- unsigned Depth) const override;
+ bool canCreateUndefOrPoisonForTargetNode(
+ SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
+ UndefPoisonKind Kind, bool ConsiderFlags, unsigned Depth) const override;
bool isTargetCanonicalConstantNode(SDValue Op) const override;
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
index e05213b2aaf93..ee41e5bf73ae2 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
@@ -6070,7 +6070,8 @@ void AMDGPUTargetLowering::computeKnownBitsForTargetNode(
bool SelfMultiply = Op.getOperand(0) == Op.getOperand(1);
if (SelfMultiply)
SelfMultiply &= DAG.isGuaranteedNotToBeUndefOrPoison(
- Op.getOperand(0), DemandedElts, false, Depth + 1);
+ Op.getOperand(0), DemandedElts, UndefPoisonKind::UndefOrPoison,
+ Depth + 1);
Known = KnownBits::mul(LHSKnown, RHSKnown, SelfMultiply);
break;
@@ -6259,7 +6260,7 @@ unsigned AMDGPUTargetLowering::computeNumSignBitsForTargetInstr(
bool AMDGPUTargetLowering::canCreateUndefOrPoisonForTargetNode(
SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
- bool PoisonOnly, bool ConsiderFlags, unsigned Depth) const {
+ UndefPoisonKind Kind, bool ConsiderFlags, unsigned Depth) const {
unsigned Opcode = Op.getOpcode();
switch (Opcode) {
case AMDGPUISD::BFE_I32:
@@ -6267,7 +6268,7 @@ bool AMDGPUTargetLowering::canCreateUndefOrPoisonForTargetNode(
return false;
}
return TargetLowering::canCreateUndefOrPoisonForTargetNode(
- Op, DemandedElts, DAG, PoisonOnly, ConsiderFlags, Depth);
+ Op, DemandedElts, DAG, Kind, ConsiderFlags, Depth);
}
bool AMDGPUTargetLowering::isKnownNeverNaNForTargetNode(
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
index 8085b64567c59..fc61fe033de0e 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
@@ -342,11 +342,9 @@ class AMDGPUTargetLowering : public TargetLowering {
const MachineRegisterInfo &MRI,
unsigned Depth = 0) const override;
- bool canCreateUndefOrPoisonForTargetNode(SDValue Op,
- const APInt &DemandedElts,
- const SelectionDAG &DAG,
- bool PoisonOnly, bool ConsiderFlags,
- unsigned Depth) const override;
+ bool canCreateUndefOrPoisonForTargetNode(
+ SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
+ UndefPoisonKind Kind, bool ConsiderFlags, unsigned Depth) const override;
bool isKnownNeverNaNForTargetNode(SDValue Op, const APInt &DemandedElts,
const SelectionDAG &DAG, bool SNaN = false,
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index cbff40f697b9b..ff8df9b33b3cc 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -21540,7 +21540,7 @@ bool ARMTargetLowering::canCombineStoreAndExtract(Type *VectorTy, Value *Idx,
bool ARMTargetLowering::canCreateUndefOrPoisonForTargetNode(
SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
- bool PoisonOnly, bool ConsiderFlags, unsigned Depth) const {
+ UndefPoisonKind Kind, bool ConsiderFlags, unsigned Depth) const {
unsigned Opcode = Op.getOpcode();
switch (Opcode) {
case ARMISD::VORRIMM:
@@ -21548,7 +21548,7 @@ bool ARMTargetLowering::canCreateUndefOrPoisonForTargetNode(
return false;
}
return TargetLowering::canCreateUndefOrPoisonForTargetNode(
- Op, DemandedElts, DAG, PoisonOnly, ConsiderFlags, Depth);
+ Op, DemandedElts, DAG, Kind, ConsiderFlags, Depth);
}
bool ARMTargetLowering::isCheapToSpeculateCttz(Type *Ty) const {
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.h b/llvm/lib/Target/ARM/ARMISelLowering.h
index 491beb5434555..10f5442d7429b 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.h
+++ b/llvm/lib/Target/ARM/ARMISelLowering.h
@@ -402,9 +402,12 @@ class VectorType;
bool canCombineStoreAndExtract(Type *VectorTy, Value *Idx,
unsigned &Cost) const override;
- bool canCreateUndefOrPoisonForTargetNode(
- SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
- bool PoisonOnly, bool ConsiderFlags, unsigned Depth) const override;
+ bool canCreateUndefOrPoisonForTargetNode(SDValue Op,
+ const APInt &DemandedElts,
+ const SelectionDAG &DAG,
+ UndefPoisonKind Kind,
+ bool ConsiderFlags,
+ unsigned Depth) const override;
bool canMergeStoresTo(unsigned AddressSpace, EVT MemVT,
const MachineFunction &MF) const override {
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index d126616312748..2856d72fbe1f8 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -22973,7 +22973,7 @@ bool RISCVTargetLowering::SimplifyDemandedBitsForTargetNode(
bool RISCVTargetLowering::canCreateUndefOrPoisonForTargetNode(
SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
- bool PoisonOnly, bool ConsiderFlags, unsigned Depth) const {
+ UndefPoisonKind Kind, bool ConsiderFlags, unsigned Depth) const {
// TODO: Add more target nodes.
switch (Op.getOpcode()) {
@@ -22994,7 +22994,7 @@ bool RISCVTargetLowering::canCreateUndefOrPoisonForTargetNode(
return false;
}
return TargetLowering::canCreateUndefOrPoisonForTargetNode(
- Op, DemandedElts, DAG, PoisonOnly, ConsiderFlags, Depth);
+ Op, DemandedElts, DAG, Kind, ConsiderFlags, Depth);
}
const Constant *
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.h b/llvm/lib/Target/RISCV/RISCVISelLowering.h
index 1be58c56d56d7..54802cf62a13e 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.h
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.h
@@ -157,11 +157,9 @@ class RISCVTargetLowering : public TargetLowering {
TargetLoweringOpt &TLO,
unsigned Depth) const override;
- bool canCreateUndefOrPoisonForTargetNode(SDValue Op,
- const APInt &DemandedElts,
- const SelectionDAG &DAG,
- bool PoisonOnly, bool ConsiderFlags,
- unsigned Depth) const override;
+ bool canCreateUndefOrPoisonForTargetNode(
+ SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
+ UndefPoisonKind Kind, bool ConsiderFlags, unsigned Depth) const override;
const Constant *getTargetConstantFromLoad(LoadSDNode *LD) const override;
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index bacedc787a477..8084aebe0ba52 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -9679,10 +9679,9 @@ SystemZTargetLowering::ComputeNumSignBitsForTargetNode(
return 1;
}
-bool SystemZTargetLowering::
-isGuaranteedNotToBeUndefOrPoisonForTargetNode(SDValue Op,
- const APInt &DemandedElts, const SelectionDAG &DAG,
- bool PoisonOnly, unsigned Depth) const {
+bool SystemZTargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode(
+ SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
+ UndefPoisonKind Kind, unsigned Depth) const {
switch (Op->getOpcode()) {
case SystemZISD::PCREL_WRAPPER:
case SystemZISD::PCREL_OFFSET:
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.h b/llvm/lib/Target/SystemZ/SystemZISelLowering.h
index bb3eeba6446d2..65197bbf0ee1d 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.h
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.h
@@ -294,7 +294,7 @@ class SystemZTargetLowering : public TargetLowering {
bool isGuaranteedNotToBeUndefOrPoisonForTargetNode(
SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
- bool PoisonOnly, unsigned Depth) const override;
+ UndefPoisonKind Kind, unsigned Depth) const override;
ISD::NodeType getExtendForAtomicOps() const override {
return ISD::ANY_EXTEND;
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 5a1171b2b4ee6..e580715151186 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -45977,7 +45977,7 @@ SDValue X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(
bool X86TargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode(
SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
- bool PoisonOnly, unsigned Depth) const {
+ UndefPoisonKind Kind, unsigned Depth) const {
unsigned NumElts = DemandedElts.getBitWidth();
switch (Op.getOpcode()) {
@@ -45996,10 +45996,10 @@ bool X86TargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode(
DemandedRHS);
return (!DemandedLHS ||
DAG.isGuaranteedNotToBeUndefOrPoison(Op.getOperand(0), DemandedLHS,
- PoisonOnly, Depth + 1)) &&
+ Kind, Depth + 1)) &&
(!DemandedRHS ||
DAG.isGuaranteedNotToBeUndefOrPoison(Op.getOperand(1), DemandedRHS,
- PoisonOnly, Depth + 1));
+ Kind, Depth + 1));
}
case X86ISD::INSERTPS:
case X86ISD::BLENDI:
@@ -46033,7 +46033,7 @@ bool X86TargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode(
for (auto Op : enumerate(Ops))
if (!DemandedSrcElts[Op.index()].isZero() &&
!DAG.isGuaranteedNotToBeUndefOrPoison(
- Op.value(), DemandedSrcElts[Op.index()], PoisonOnly, Depth + 1))
+ Op.value(), DemandedSrcElts[Op.index()], Kind, Depth + 1))
return false;
return true;
}
@@ -46044,19 +46044,19 @@ bool X86TargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode(
MVT SrcVT = Src.getSimpleValueType();
if (SrcVT.isVector()) {
APInt DemandedSrc = APInt::getOneBitSet(SrcVT.getVectorNumElements(), 0);
- return DAG.isGuaranteedNotToBeUndefOrPoison(Src, DemandedSrc, PoisonOnly,
+ return DAG.isGuaranteedNotToBeUndefOrPoison(Src, DemandedSrc, Kind,
Depth + 1);
}
- return DAG.isGuaranteedNotToBeUndefOrPoison(Src, PoisonOnly, Depth + 1);
+ return DAG.isGuaranteedNotToBeUndefOrPoison(Src, Kind, Depth + 1);
}
}
return TargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode(
- Op, DemandedElts, DAG, PoisonOnly, Depth);
+ Op, DemandedElts, DAG, Kind, Depth);
}
bool X86TargetLowering::canCreateUndefOrPoisonForTargetNode(
SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
- bool PoisonOnly, bool ConsiderFlags, unsigned Depth) const {
+ UndefPoisonKind Kind, bool ConsiderFlags, unsigned Depth) const {
switch (Op.getOpcode()) {
// SSE bit logic.
@@ -46152,7 +46152,7 @@ bool X86TargetLowering::canCreateUndefOrPoisonForTargetNode(
}
}
return TargetLowering::canCreateUndefOrPoisonForTargetNode(
- Op, DemandedElts, DAG, PoisonOnly, ConsiderFlags, Depth);
+ Op, DemandedElts, DAG, Kind, ConsiderFlags, Depth);
}
bool X86TargetLowering::isSplatValueForTargetNode(SDValue Op,
diff --git a/llvm/lib/Target/X86/X86ISelLowering.h b/llvm/lib/Target/X86/X86ISelLowering.h
index 515f28122a00a..0d05c5772a707 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.h
+++ b/llvm/lib/Target/X86/X86ISelLowering.h
@@ -367,11 +367,14 @@ namespace llvm {
bool isGuaranteedNotToBeUndefOrPoisonForTargetNode(
SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
- bool PoisonOnly, unsigned Depth) const override;
+ UndefPoisonKind Kind, unsigned Depth) const override;
- bool canCreateUndefOrPoisonForTargetNode(
- SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
- bool PoisonOnly, bool ConsiderFlags, unsigned Depth) const override;
+ bool canCreateUndefOrPoisonForTargetNode(SDValue Op,
+ const APInt &DemandedElts,
+ const SelectionDAG &DAG,
+ UndefPoisonKind Kind,
+ bool ConsiderFlags,
+ unsigned Depth) const override;
bool isSplatValueForTargetNode(SDValue Op, const APInt &DemandedElts,
APInt &UndefElts, const SelectionDAG &DAG,
>From 907058be661836ff039e82ef2df173af2302482e Mon Sep 17 00:00:00 2001
From: Simon Pilgrim <llvm-dev at redking.me.uk>
Date: Wed, 6 May 2026 22:30:32 +0100
Subject: [PATCH 2/2] Update DAG::getFreeze to use UndefPoisonKind as well
---
llvm/include/llvm/CodeGen/SelectionDAG.h | 7 ++++---
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 4 ++--
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 4 +---
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h
index 9a237821ac378..fba44dca6800c 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAG.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -1772,9 +1772,10 @@ class SelectionDAG {
LLVM_ABI SDValue getFreeze(SDValue V);
/// Return a freeze of V if any of the demanded elts may be undef or poison.
- /// If \p PoisonOnly is true, then only check for poison elements.
- LLVM_ABI SDValue getFreeze(SDValue V, const APInt &DemandedElts,
- bool PoisonOnly = false);
+ /// \p Kind can be used to selectively freeze poison and/or undef bits only.
+ LLVM_ABI SDValue
+ getFreeze(SDValue V, const APInt &DemandedElts,
+ UndefPoisonKind Kind = UndefPoisonKind::UndefOrPoison);
/// Return an AssertAlignSDNode.
LLVM_ABI SDValue getAssertAlign(const SDLoc &DL, SDValue V, Align A);
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 6ddfbe1755fad..15577af91ff03 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -24827,8 +24827,8 @@ SDValue DAGCombiner::visitINSERT_VECTOR_ELT(SDNode *N) {
// Make sure to freeze the source vector in case any of the elements
// overwritten by the insert may be poison. Otherwise those elements
// could end up being poison instead of 0/-1 after the AND/OR.
- CurVec =
- DAG.getFreeze(CurVec, InsertedEltMask, /*PoisonOnly=*/true);
+ CurVec = DAG.getFreeze(CurVec, InsertedEltMask,
+ UndefPoisonKind::PoisonOnly);
return DAG.getNode(MaskOpcode, DL, VT, CurVec,
DAG.getBuildVector(VT, DL, Mask));
};
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 95c3dc4c3d88a..a50db7c007890 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -2570,9 +2570,7 @@ SDValue SelectionDAG::getFreeze(SDValue V) {
}
SDValue SelectionDAG::getFreeze(SDValue V, const APInt &DemandedElts,
- bool PoisonOnly) {
- UndefPoisonKind Kind =
- PoisonOnly ? UndefPoisonKind::PoisonOnly : UndefPoisonKind::UndefOrPoison;
+ UndefPoisonKind Kind) {
if (isGuaranteedNotToBeUndefOrPoison(V, DemandedElts, Kind))
return V;
return getFreeze(V);
More information about the llvm-commits
mailing list