[llvm-branch-commits] [llvm] 490d4ed - [GlobalISel] Fix inverted libcall status check in createFCMPLibcall (#219242)

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Aug 28 02:05:39 PDT 2026


Author: Daniel Paoliello
Date: 2026-08-28T11:05:13+02:00
New Revision: 490d4ed19d16c868c1a9e9f461282deaf05e69c3

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

LOG: [GlobalISel] Fix inverted libcall status check in createFCMPLibcall (#219242)

BuildLibcall tested `if (!Status)` on the LegalizeResult returned by
createLibcall. Since LegalizeResult is an enum with AlreadyLegal == 0,
that condition is false for both Legalized and UnableToLegalize, so a
failed libcall was never detected. The helper then built an ICMP against
the undefined result register and reported success, so the legalizer
never fell back.

Check `Status != Legalized` instead, so failures propagate and the
caller can bail out.

On arm64ec, GlobalISel call lowering is unimplemented, so this silently
dropped `fp128` compare libcalls at `-O0`. Add a test that checks the
expected `__eqtf2`, `__lttf2` and `__unordtf2` calls are emitted at both
`-O0` and `-O2`.

(cherry picked from commit ded76cf640b9b7c1425f9543c54da402bbda7ca5)

Added: 
    llvm/test/CodeGen/AArch64/arm64ec-fp128-cmp.ll

Modified: 
    llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index 41630c70ebeb6..94d43578ed989 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -1190,7 +1190,7 @@ LegalizerHelper::createFCMPLibcall(MachineInstr &MI,
         Libcall, {Temp, Type::getInt32Ty(Ctx), 0},
         {{Cmp->getLHSReg(), OpType, 0}, {Cmp->getRHSReg(), OpType, 1}},
         LocObserver, &MI);
-    if (!Status)
+    if (Status != Legalized)
       return {};
 
     // Compare temp with #0 to get the final result.

diff  --git a/llvm/test/CodeGen/AArch64/arm64ec-fp128-cmp.ll b/llvm/test/CodeGen/AArch64/arm64ec-fp128-cmp.ll
new file mode 100644
index 0000000000000..db3df7737743f
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/arm64ec-fp128-cmp.ll
@@ -0,0 +1,33 @@
+; GlobalISel is the default selector at -O0, but Arm64EC call lowering is
+; unimplemented there, so fp128 compares must fall back to SelectionDAG rather
+; than silently dropping the libcall.
+; RUN: llc -mtriple=arm64ec-pc-windows-msvc -O0 < %s | FileCheck %s
+; RUN: llc -mtriple=arm64ec-pc-windows-msvc -O2 < %s | FileCheck %s
+
+define i1 @cmp_oeq(fp128 %a, fp128 %b) {
+; CHECK-LABEL: "#cmp_oeq":
+; CHECK: bl "#__eqtf2"
+  %r = fcmp oeq fp128 %a, %b
+  ret i1 %r
+}
+
+define i1 @cmp_olt(fp128 %a, fp128 %b) {
+; CHECK-LABEL: "#cmp_olt":
+; CHECK: bl "#__lttf2"
+  %r = fcmp olt fp128 %a, %b
+  ret i1 %r
+}
+
+define i1 @cmp_uno(fp128 %a, fp128 %b) {
+; CHECK-LABEL: "#cmp_uno":
+; CHECK: bl "#__unordtf2"
+  %r = fcmp uno fp128 %a, %b
+  ret i1 %r
+}
+
+define i1 @cmp_une_self(fp128 %a) {
+; CHECK-LABEL: "#cmp_une_self":
+; CHECK: bl "#__unordtf2"
+  %r = fcmp une fp128 %a, %a
+  ret i1 %r
+}


        


More information about the llvm-branch-commits mailing list