[llvm] [NVPTX] Fix lowering of i1 SETCC (PR #115035)

Justin Fargnoli via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 15 15:07:22 PST 2024


================
@@ -11874,6 +11874,47 @@ bool TargetLowering::LegalizeSetCCCondCode(SelectionDAG &DAG, EVT VT,
       return true;
     }
 
+    // Special case: expand i1 comparisons using logical operations.
+    if (OpVT == MVT::i1) {
+      SDValue Ret;
+      switch (CCCode) {
+      default:
+        llvm_unreachable("Unknown integer setcc!");
+      case ISD::SETEQ: // X == Y  -->  ~(X ^ Y)
+        Ret = DAG.getNOT(dl, DAG.getNode(ISD::XOR, dl, MVT::i1, LHS, RHS),
----------------
justinfargnoli wrote:

Does this need to be guarded by `TLI.isLegal(ISD::XOR)`?

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


More information about the llvm-commits mailing list