[llvm] r296502 - [DAGCombiner] use dyn_cast values in foldSelectOfConstants(); NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 28 10:41:50 PST 2017
Author: spatel
Date: Tue Feb 28 12:41:49 2017
New Revision: 296502
URL: http://llvm.org/viewvc/llvm-project?rev=296502&view=rev
Log:
[DAGCombiner] use dyn_cast values in foldSelectOfConstants(); NFC
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=296502&r1=296501&r2=296502&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue Feb 28 12:41:49 2017
@@ -5677,7 +5677,9 @@ SDValue DAGCombiner::foldSelectOfConstan
if (!VT.isInteger())
return SDValue();
- if (!isa<ConstantSDNode>(N1) || !isa<ConstantSDNode>(N2))
+ auto *C1 = dyn_cast<ConstantSDNode>(N1);
+ auto *C2 = dyn_cast<ConstantSDNode>(N2);
+ if (!C1 || !C2)
return SDValue();
// Only do this before legalization to avoid conflicting with target-specific
@@ -5687,27 +5689,27 @@ SDValue DAGCombiner::foldSelectOfConstan
// TODO: This could be generalized for any 2 constants that differ by 1:
// add ({s/z}ext Cond), C
if (CondVT == MVT::i1 && !LegalOperations) {
- if (isNullConstant(N1) && isOneConstant(N2)) {
+ if (C1->isNullValue() && C2->isOne()) {
// select Cond, 0, 1 --> zext (!Cond)
SDValue NotCond = DAG.getNOT(DL, Cond, MVT::i1);
if (VT != MVT::i1)
NotCond = DAG.getNode(ISD::ZERO_EXTEND, DL, VT, NotCond);
return NotCond;
}
- if (isNullConstant(N1) && isAllOnesConstant(N2)) {
+ if (C1->isNullValue() && C2->isAllOnesValue()) {
// select Cond, 0, -1 --> sext (!Cond)
SDValue NotCond = DAG.getNOT(DL, Cond, MVT::i1);
if (VT != MVT::i1)
NotCond = DAG.getNode(ISD::SIGN_EXTEND, DL, VT, NotCond);
return NotCond;
}
- if (isOneConstant(N1) && isNullConstant(N2)) {
+ if (C1->isOne() && C2->isNullValue()) {
// select Cond, 1, 0 --> zext (Cond)
if (VT != MVT::i1)
Cond = DAG.getNode(ISD::ZERO_EXTEND, DL, VT, Cond);
return Cond;
}
- if (isAllOnesConstant(N1) && isNullConstant(N2)) {
+ if (C1->isAllOnesValue() && C2->isNullValue()) {
// select Cond, -1, 0 --> sext (Cond)
if (VT != MVT::i1)
Cond = DAG.getNode(ISD::SIGN_EXTEND, DL, VT, Cond);
@@ -5730,7 +5732,7 @@ SDValue DAGCombiner::foldSelectOfConstan
TargetLowering::ZeroOrOneBooleanContent &&
TLI.getBooleanContents(false, false) ==
TargetLowering::ZeroOrOneBooleanContent &&
- isNullConstant(N1) && isOneConstant(N2)) {
+ C1->isNullValue() && C2->isOne()) {
SDValue NotCond =
DAG.getNode(ISD::XOR, DL, CondVT, Cond, DAG.getConstant(1, DL, CondVT));
if (VT.bitsEq(CondVT))
More information about the llvm-commits
mailing list