[llvm] [X86][GlobalISel] Support G_SELECT for x86_fp80 (PR #157377)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 7 20:05:26 PDT 2025


================
@@ -0,0 +1,41 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc < %s -fast-isel -fast-isel-abort=1 -verify-machineinstrs | FileCheck %s
+; RUN: llc < %s -global-isel -global-isel-abort=1 -verify-machineinstrs | FileCheck %s --check-prefix=GISEL
+; RUN: llc < %s -fast-isel=0 -global-isel=0 -verify-machineinstrs | FileCheck %s
+
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-unknown"
+
+; Test that we can generate an fcmove, and also that it passes verification.
+
+define x86_fp80 @cmove_f(x86_fp80 %a, x86_fp80 %b, i32 %c) {
+; CHECK-LABEL: cmove_f:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    fldt {{[0-9]+}}(%rsp)
+; CHECK-NEXT:    fldt {{[0-9]+}}(%rsp)
+; CHECK-NEXT:    testl %edi, %edi
+; CHECK-NEXT:    fadd %st(1), %st
+; CHECK-NEXT:    fxch %st(1)
+; CHECK-NEXT:    fcmove %st(1), %st
+; CHECK-NEXT:    fstp %st(1)
+; CHECK-NEXT:    retq
+;
+; GISEL-LABEL: cmove_f:
+; GISEL:       # %bb.0:
+; GISEL-NEXT:    fldt {{[0-9]+}}(%rsp)
+; GISEL-NEXT:    fldt {{[0-9]+}}(%rsp)
+; GISEL-NEXT:    xorl %eax, %eax
+; GISEL-NEXT:    cmpl $0, %edi
+; GISEL-NEXT:    sete %al
+; GISEL-NEXT:    fadd %st, %st(1)
+; GISEL-NEXT:    andl $1, %eax
+; GISEL-NEXT:    testl %eax, %eax
+; GISEL-NEXT:    fxch %st(1)
+; GISEL-NEXT:    fcmove %st(1), %st
+; GISEL-NEXT:    fstp %st(1)
+; GISEL-NEXT:    retq
+  %test = icmp eq i32 %c, 0
+  %add = fadd x86_fp80 %a, %b
+  %ret = select i1 %test, x86_fp80 %add, x86_fp80 %b
+  ret x86_fp80 %ret
+}
----------------
arsenm wrote:

Can you also test a case where the condition doesn't come from a compare, like it's a load or argument 

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


More information about the llvm-commits mailing list