[llvm] d6501dc - [X86][AVX512] Check input-types to COMX (#118606)

via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 8 20:55:12 PST 2024


Author: abhishek-kaushik22
Date: 2024-12-09T12:55:07+08:00
New Revision: d6501dc88d5e040b31ffb83ebcf02c941c7c964f

URL: https://github.com/llvm/llvm-project/commit/d6501dc88d5e040b31ffb83ebcf02c941c7c964f
DIFF: https://github.com/llvm/llvm-project/commit/d6501dc88d5e040b31ffb83ebcf02c941c7c964f.diff

LOG: [X86][AVX512] Check input-types to COMX (#118606)

Supported types for COMX are f16, f32 and f64. 
Without this check there's a crash on f80 types.
Fixes: https://github.com/llvm/llvm-project/issues/118605

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86ISelLowering.cpp
    llvm/test/CodeGen/X86/avx10_2-cmp.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index fb8e791d8ec981..5c6b22896edd0f 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -24235,8 +24235,10 @@ SDValue X86TargetLowering::LowerSETCC(SDValue Op, SelectionDAG &DAG) const {
   if (Subtarget.hasAVX10_2()) {
     if (CC == ISD::SETOEQ || CC == ISD::SETUNE) {
       auto NewCC = (CC == ISD::SETOEQ) ? X86::COND_E : (X86::COND_NE);
-      return getSETCC(NewCC, DAG.getNode(X86ISD::UCOMX, dl, MVT::i32, Op0, Op1),
-                      dl, DAG);
+      assert(Op0.getSimpleValueType() != MVT::bf16 && "Unsupported Type");
+      if (Op0.getSimpleValueType() != MVT::f80)
+        return getSETCC(
+            NewCC, DAG.getNode(X86ISD::UCOMX, dl, MVT::i32, Op0, Op1), dl, DAG);
     }
   }
   // Handle floating point.

diff  --git a/llvm/test/CodeGen/X86/avx10_2-cmp.ll b/llvm/test/CodeGen/X86/avx10_2-cmp.ll
index de0bec7ea2695a..140a20c17ea6de 100644
--- a/llvm/test/CodeGen/X86/avx10_2-cmp.ll
+++ b/llvm/test/CodeGen/X86/avx10_2-cmp.ll
@@ -235,3 +235,44 @@ define i1 @dune_mem(ptr %xp, ptr %yp) {
     %1 = fcmp une double %x, %y
     ret i1 %1
 }
+
+define i32 @PR118606(x86_fp80 %val1) #0 {
+; X64-LABEL: PR118606:
+; X64:       # %bb.0: # %entry
+; X64-NEXT:    fldt {{[0-9]+}}(%rsp)
+; X64-NEXT:    fldz
+; X64-NEXT:    fucomi %st(1), %st
+; X64-NEXT:    fstp %st(1)
+; X64-NEXT:    fld1
+; X64-NEXT:    fcmovne %st(1), %st
+; X64-NEXT:    fcmovu %st(1), %st
+; X64-NEXT:    fucompi %st(1), %st
+; X64-NEXT:    fstp %st(0)
+; X64-NEXT:    xorl %eax, %eax
+; X64-NEXT:    retq
+;
+; X86-LABEL: PR118606:
+; X86:       # %bb.0: # %entry
+; X86-NEXT:    fldt {{[0-9]+}}(%esp)
+; X86-NEXT:    fldz
+; X86-NEXT:    fucomi %st(1), %st
+; X86-NEXT:    fstp %st(1)
+; X86-NEXT:    fld1
+; X86-NEXT:    fcmovne %st(1), %st
+; X86-NEXT:    fcmovu %st(1), %st
+; X86-NEXT:    fucompi %st(1), %st
+; X86-NEXT:    fstp %st(0)
+; X86-NEXT:    xorl %eax, %eax
+; X86-NEXT:    retl
+entry:
+  %cmp8 = fcmp oeq x86_fp80 %val1, 0xK00000000000000000000
+  %0 = select i1 %cmp8, x86_fp80 0xK3FFF8000000000000000, x86_fp80 0xK00000000000000000000
+  %cmp64 = fcmp ogt x86_fp80 %0, 0xK00000000000000000000
+  br i1 %cmp64, label %if.then66, label %if.end70
+
+if.then66:                                        ; preds = %entry
+  ret i32 0
+
+if.end70:                                         ; preds = %entry
+  ret i32 0
+}


        


More information about the llvm-commits mailing list