Skip to content

Commit

Permalink
[DAG] Add optional AllowUndefs to isNullOrNullSplat
Browse files Browse the repository at this point in the history
No change in default behaviour (AllowUndefs = false)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353646 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
RKSimon committed Feb 10, 2019
1 parent bdd96a7 commit 86334b3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions include/llvm/CodeGen/SelectionDAGNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1633,9 +1633,9 @@ ConstantSDNode *isConstOrConstSplat(SDValue N, bool AllowUndefs = false);
ConstantFPSDNode *isConstOrConstSplatFP(SDValue N, bool AllowUndefs = false);

/// Return true if the value is a constant 0 integer or a splatted vector of
/// a constant 0 integer (with no undefs).
/// a constant 0 integer (with no undefs by default).
/// Build vector implicit truncation is not an issue for null values.
bool isNullOrNullSplat(SDValue V);
bool isNullOrNullSplat(SDValue V, bool AllowUndefs = false);

/// Return true if the value is a constant 1 integer or a splatted vector of a
/// constant 1 integer (with no undefs).
Expand Down
6 changes: 1 addition & 5 deletions lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7128,11 +7128,7 @@ SDValue DAGCombiner::visitFunnelShift(SDNode *N) {
return IsFSHL ? N0 : N1;

auto IsUndefOrZero = [](SDValue V) {
if (V.isUndef())
return true;
if (ConstantSDNode *Cst = isConstOrConstSplat(V, /*AllowUndefs*/true))
return Cst->getAPIntValue() == 0;
return false;
return V.isUndef() || isNullOrNullSplat(V, /*AllowUndefs*/ true);
};

if (ConstantSDNode *Cst = isConstOrConstSplat(N2)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8622,9 +8622,9 @@ ConstantFPSDNode *llvm::isConstOrConstSplatFP(SDValue N, bool AllowUndefs) {
return nullptr;
}

bool llvm::isNullOrNullSplat(SDValue N) {
bool llvm::isNullOrNullSplat(SDValue N, bool AllowUndefs) {
// TODO: may want to use peekThroughBitcast() here.
ConstantSDNode *C = isConstOrConstSplat(N);
ConstantSDNode *C = isConstOrConstSplat(N, AllowUndefs);
return C && C->isNullValue();
}

Expand Down

0 comments on commit 86334b3

Please sign in to comment.