This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Support VP_SETCC mask operations
ClosedPublic

Authored by Jimerlife on Apr 26 2022, 1:02 AM.

Details

Summary

Support VP_SETCC mask operations, turn it to logical operation.

Diff Detail

Event Timeline

Jimerlife created this revision.Apr 26 2022, 1:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2022, 1:02 AM
Jimerlife requested review of this revision.Apr 26 2022, 1:02 AM
craig.topper added inline comments.Apr 26 2022, 10:06 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
6140

I don't think these are correct. Here's the equivalent code for regular setcc

case ISD::SETGT:  // X >s Y   -->  X == 0 & Y == 1  -->  ~X & Y
case ISD::SETULT: // X <u Y   -->  X == 0 & Y == 1  -->  ~X & Y
  Temp = DAG.getNOT(dl, N0, OpVT);
  N0 = DAG.getNode(ISD::AND, dl, OpVT, N1, Temp);
  if (!DCI.isCalledByLegalizer())
    DCI.AddToWorklist(Temp.getNode());
  break;
case ISD::SETLT:  // X <s Y   --> X == 1 & Y == 0  -->  ~Y & X
case ISD::SETUGT: // X >u Y   --> X == 1 & Y == 0  -->  ~Y & X
  Temp = DAG.getNOT(dl, N1, OpVT);
  N0 = DAG.getNode(ISD::AND, dl, OpVT, N0, Temp);
  if (!DCI.isCalledByLegalizer())
    DCI.AddToWorklist(Temp.getNode());
  break;
case ISD::SETULE: // X <=u Y  --> X == 0 | Y == 1  -->  ~X | Y
case ISD::SETGE:  // X >=s Y  --> X == 0 | Y == 1  -->  ~X | Y
  Temp = DAG.getNOT(dl, N0, OpVT);
  N0 = DAG.getNode(ISD::OR, dl, OpVT, N1, Temp);
  if (!DCI.isCalledByLegalizer())
    DCI.AddToWorklist(Temp.getNode());
  break;
case ISD::SETUGE: // X >=u Y  --> X == 1 | Y == 0  -->  ~Y | X
case ISD::SETLE:  // X <=s Y  --> X == 1 | Y == 0  -->  ~Y | X
  Temp = DAG.getNOT(dl, N1, OpVT);
  N0 = DAG.getNode(ISD::OR, dl, OpVT, N0, Temp);
  break;
}

rebase and update code according to comment.

Jimerlife marked an inline comment as done.Apr 27 2022, 12:57 AM
Jimerlife added inline comments.
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
6140

I have adjusted code according to regular setcc. Thanks for your advice.

Jimerlife marked an inline comment as done.Apr 27 2022, 1:00 AM
This revision is now accepted and ready to land.Apr 27 2022, 10:31 AM
This revision was landed with ongoing or failed builds.Apr 28 2022, 1:53 AM
This revision was automatically updated to reflect the committed changes.