[llvm] [Xtensa] Implement lowering SELECT_CC, SETCC. (PR #97017)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 04:46:16 PDT 2024


================
@@ -697,6 +718,126 @@ const char *XtensaTargetLowering::getTargetNodeName(unsigned Opcode) const {
     return "XtensaISD::PCREL_WRAPPER";
   case XtensaISD::RET:
     return "XtensaISD::RET";
+  case XtensaISD::SELECT_CC:
+    return "XtensaISD::SELECT_CC";
   }
   return nullptr;
 }
+
+//===----------------------------------------------------------------------===//
+// Custom insertion
+//===----------------------------------------------------------------------===//
+
+static int GetBranchKind(int Cond, bool &BrInv) {
+  switch (Cond) {
+  case ISD::SETEQ:
+    return Xtensa::BEQ;
+  case ISD::SETNE:
+    return Xtensa::BNE;
+  case ISD::SETLT:
+    return Xtensa::BLT;
+  case ISD::SETLE:
+    BrInv = true;
+    return Xtensa::BGE;
+  case ISD::SETGT:
+    BrInv = true;
+    return Xtensa::BLT;
+  case ISD::SETGE:
+    return Xtensa::BGE;
+  case ISD::SETULT:
+    return Xtensa::BLTU;
+  case ISD::SETULE:
+    BrInv = true;
----------------
s-barannikov wrote:

It is worth investigating why this happens.

> Should we strive to always rely on general approaches to lower Operations(like use setCondCodeAction), or in some cases (like that) we can use target specific implementation?

This is not a requirement, but usually you woulnd't want to re-implement what DAG passes already do.


https://github.com/llvm/llvm-project/pull/97017


More information about the llvm-commits mailing list