Skip to content

Commit 20020c1

Browse files
authored
[DAGCombiner] Fix misuse of getZeroExtendInReg in SimplifySelectCC. (#70066)
If VT has less bits than SCC, using a ZeroExtendInReg isn't going to fix it. That's an AND instruction. We need to truncate the value instead. This should be ok because we already checked that the boolean contents is ZeroOrOne so the setcc can only produce 0 or 1. No test because I found this while trying to make i32 legal for RISC-V 64 which I'm not ready to upload yet. You can see in the coverage report that this line isn't tested today. https://lab.llvm.org/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp.html#L27270
1 parent 8244ff6 commit 20020c1

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27274,10 +27274,7 @@ SDValue DAGCombiner::SimplifySelectCC(const SDLoc &DL, SDValue N0, SDValue N1,
2727427274
// zext (setcc n0, n1)
2727527275
if (LegalTypes) {
2727627276
SCC = DAG.getSetCC(DL, CmpResVT, N0, N1, CC);
27277-
if (VT.bitsLT(SCC.getValueType()))
27278-
Temp = DAG.getZeroExtendInReg(SCC, SDLoc(N2), VT);
27279-
else
27280-
Temp = DAG.getNode(ISD::ZERO_EXTEND, SDLoc(N2), VT, SCC);
27277+
Temp = DAG.getZExtOrTrunc(SCC, SDLoc(N2), VT);
2728127278
} else {
2728227279
SCC = DAG.getSetCC(SDLoc(N0), MVT::i1, N0, N1, CC);
2728327280
Temp = DAG.getNode(ISD::ZERO_EXTEND, SDLoc(N2), VT, SCC);

0 commit comments

Comments
 (0)