From 3ec5d74fc5bc03bdb3ab5876799dff4d82e38193 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 9 Sep 2005 23:00:07 +0000 Subject: [PATCH] Fix a problem duraid encountered on itanium where this folding: select (x < y), 1, 0 -> (x < y) incorrectly: the setcc returns i1 but the select returned i32. Add the zero extend as needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23301 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index c27523ae131..79ba3d20420 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -974,8 +974,12 @@ SDOperand SelectionDAG::SimplifySelectCC(SDOperand N1, SDOperand N2, // Check to see if this is the equivalent of setcc if (N4C && N4C->isNullValue() && N3C && (N3C->getValue() == 1ULL)) { MVT::ValueType XType = N1.getValueType(); - if (TLI.isOperationLegal(ISD::SETCC, TLI.getSetCCResultTy())) - return getSetCC(TLI.getSetCCResultTy(), N1, N2, CC); + if (TLI.isOperationLegal(ISD::SETCC, TLI.getSetCCResultTy())) { + SDOperand Res = getSetCC(TLI.getSetCCResultTy(), N1, N2, CC); + if (Res.getValueType() != VT) + Res = getNode(ISD::ZERO_EXTEND, VT, Res); + return Res; + } // seteq X, 0 -> srl (ctlz X, log2(size(X))) if (N2C && N2C->isNullValue() && CC == ISD::SETEQ && -- 2.34.1