Skip to content

[X86][GlobalISel] Enable POW/EXP*/LOG* functions with libcall mapping #130328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2025

Conversation

JaydeepChauhan14
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Mar 7, 2025

@llvm/pr-subscribers-llvm-globalisel

@llvm/pr-subscribers-backend-x86

Author: None (JaydeepChauhan14)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/130328.diff

3 Files Affected:

  • (modified) llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp (+2-1)
  • (modified) llvm/test/CodeGen/X86/exp10-libcall-names.ll (+20-9)
  • (modified) llvm/test/CodeGen/X86/finite-libcalls.ll (+117-48)
diff --git a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
index 684580d6fca06..24bf0dd378641 100644
--- a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
+++ b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
@@ -101,7 +101,8 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI,
 
   getActionDefinitionsBuilder({G_LROUND, G_LLROUND, G_FCOS, G_FCOSH, G_FACOS,
                                G_FSIN, G_FSINH, G_FASIN, G_FTAN, G_FTANH,
-                               G_FATAN, G_FATAN2})
+                               G_FATAN, G_FATAN2, G_FPOW, G_FEXP, G_FEXP2,
+                               G_FEXP10, G_FLOG, G_FLOG2, G_FLOG10})
       .libcall();
 
   // merge/unmerge
diff --git a/llvm/test/CodeGen/X86/exp10-libcall-names.ll b/llvm/test/CodeGen/X86/exp10-libcall-names.ll
index 94265813adc26..96e3aae408e94 100644
--- a/llvm/test/CodeGen/X86/exp10-libcall-names.ll
+++ b/llvm/test/CodeGen/X86/exp10-libcall-names.ll
@@ -10,8 +10,8 @@
 ; RUN: llc -mtriple=x86_64-apple-xros8.0 < %s | FileCheck -check-prefix=APPLE %s
 ; RUN: llc -mtriple=x86_64-apple-driverkit < %s | FileCheck -check-prefix=APPLE %s
 ; RUN: llc -mtriple=x86_64-apple-driverkit24.0 < %s | FileCheck -check-prefix=APPLE %s
-; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefix=GISEL-X86
-; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefix=GISEL-X64
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefix=GISEL-X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefix=GISEL-X64
 
 ; RUN: not llc -mtriple=x86_64-apple-macos10.8 -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
 ; Check exp10/exp10f is emitted as __exp10/__exp10f on assorted systems.
@@ -30,15 +30,18 @@ define float @test_exp10_f32(float %x) nounwind {
 ; GISEL-X86-LABEL: test_exp10_f32:
 ; GISEL-X86:       # %bb.0:
 ; GISEL-X86-NEXT:    subl $12, %esp
-; GISEL-X86-NEXT:    flds {{[0-9]+}}(%esp)
-; GISEL-X86-NEXT:    fstps (%esp)
+; GISEL-X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT:    movl %eax, (%esp)
 ; GISEL-X86-NEXT:    calll exp10f
 ; GISEL-X86-NEXT:    addl $12, %esp
 ; GISEL-X86-NEXT:    retl
 ;
 ; GISEL-X64-LABEL: test_exp10_f32:
 ; GISEL-X64:       # %bb.0:
-; GISEL-X64-NEXT:    jmp exp10f@PLT # TAILCALL
+; GISEL-X64-NEXT:    pushq %rax
+; GISEL-X64-NEXT:    callq exp10f
+; GISEL-X64-NEXT:    popq %rax
+; GISEL-X64-NEXT:    retq
   %ret = call float @llvm.exp10.f32(float %x)
   ret float %ret
 }
@@ -55,15 +58,23 @@ define double @test_exp10_f64(double %x) nounwind {
 ; GISEL-X86-LABEL: test_exp10_f64:
 ; GISEL-X86:       # %bb.0:
 ; GISEL-X86-NEXT:    subl $12, %esp
-; GISEL-X86-NEXT:    fldl {{[0-9]+}}(%esp)
-; GISEL-X86-NEXT:    fstpl (%esp)
+; GISEL-X86-NEXT:    leal {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
+; GISEL-X86-NEXT:    movl 4(%eax), %eax
+; GISEL-X86-NEXT:    xorl %edx, %edx
+; GISEL-X86-NEXT:    addl %esp, %edx
+; GISEL-X86-NEXT:    movl %ecx, (%esp)
+; GISEL-X86-NEXT:    movl %eax, 4(%edx)
 ; GISEL-X86-NEXT:    calll exp10
 ; GISEL-X86-NEXT:    addl $12, %esp
 ; GISEL-X86-NEXT:    retl
 ;
 ; GISEL-X64-LABEL: test_exp10_f64:
 ; GISEL-X64:       # %bb.0:
-; GISEL-X64-NEXT:    jmp exp10@PLT # TAILCALL
+; GISEL-X64-NEXT:    pushq %rax
+; GISEL-X64-NEXT:    callq exp10
+; GISEL-X64-NEXT:    popq %rax
+; GISEL-X64-NEXT:    retq
   %ret = call double @llvm.exp10.f64(double %x)
   ret double %ret
 }
@@ -101,7 +112,7 @@ define x86_fp80 @test_exp10_f80(x86_fp80 %x) nounwind {
 ; GISEL-X64-NEXT:    subq $24, %rsp
 ; GISEL-X64-NEXT:    fldt {{[0-9]+}}(%rsp)
 ; GISEL-X64-NEXT:    fstpt (%rsp)
-; GISEL-X64-NEXT:    callq exp10l@PLT
+; GISEL-X64-NEXT:    callq exp10l
 ; GISEL-X64-NEXT:    addq $24, %rsp
 ; GISEL-X64-NEXT:    retq
   %ret = call x86_fp80 @llvm.exp10.f80(x86_fp80 %x)
diff --git a/llvm/test/CodeGen/X86/finite-libcalls.ll b/llvm/test/CodeGen/X86/finite-libcalls.ll
index 9d0e188259c17..ea2695dc96997 100644
--- a/llvm/test/CodeGen/X86/finite-libcalls.ll
+++ b/llvm/test/CodeGen/X86/finite-libcalls.ll
@@ -2,8 +2,8 @@
 ; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu     | FileCheck %s --check-prefix=GNU
 ; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc  | FileCheck %s --check-prefix=WIN
 ; RUN: llc < %s -mtriple=x86_64-apple-darwin     | FileCheck %s --check-prefix=MAC
-; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=GISEL-X86
-; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=GISEL-X64
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X64
 
 ; PR35672 - https://bugs.llvm.org/show_bug.cgi?id=35672
 ; FIXME: We would not need the function-level attributes if FMF were propagated to DAG nodes for this case.
@@ -24,15 +24,18 @@ define float @exp_f32(float %x) #0 {
 ; GISEL-X86-LABEL: exp_f32:
 ; GISEL-X86:       # %bb.0:
 ; GISEL-X86-NEXT:    subl $12, %esp
-; GISEL-X86-NEXT:    flds {{[0-9]+}}(%esp)
-; GISEL-X86-NEXT:    fstps (%esp)
+; GISEL-X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT:    movl %eax, (%esp)
 ; GISEL-X86-NEXT:    calll expf
 ; GISEL-X86-NEXT:    addl $12, %esp
 ; GISEL-X86-NEXT:    retl
 ;
 ; GISEL-X64-LABEL: exp_f32:
 ; GISEL-X64:       # %bb.0:
-; GISEL-X64-NEXT:    jmp expf@PLT # TAILCALL
+; GISEL-X64-NEXT:    pushq %rax
+; GISEL-X64-NEXT:    callq expf
+; GISEL-X64-NEXT:    popq %rax
+; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf float @llvm.exp.f32(float %x)
   ret float %r
 }
@@ -53,15 +56,23 @@ define double @exp_f64(double %x) #0 {
 ; GISEL-X86-LABEL: exp_f64:
 ; GISEL-X86:       # %bb.0:
 ; GISEL-X86-NEXT:    subl $12, %esp
-; GISEL-X86-NEXT:    fldl {{[0-9]+}}(%esp)
-; GISEL-X86-NEXT:    fstpl (%esp)
+; GISEL-X86-NEXT:    leal {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
+; GISEL-X86-NEXT:    movl 4(%eax), %eax
+; GISEL-X86-NEXT:    xorl %edx, %edx
+; GISEL-X86-NEXT:    addl %esp, %edx
+; GISEL-X86-NEXT:    movl %ecx, (%esp)
+; GISEL-X86-NEXT:    movl %eax, 4(%edx)
 ; GISEL-X86-NEXT:    calll exp
 ; GISEL-X86-NEXT:    addl $12, %esp
 ; GISEL-X86-NEXT:    retl
 ;
 ; GISEL-X64-LABEL: exp_f64:
 ; GISEL-X64:       # %bb.0:
-; GISEL-X64-NEXT:    jmp exp@PLT # TAILCALL
+; GISEL-X64-NEXT:    pushq %rax
+; GISEL-X64-NEXT:    callq exp
+; GISEL-X64-NEXT:    popq %rax
+; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf double @llvm.exp.f64(double %x)
   ret double %r
 }
@@ -116,7 +127,7 @@ define x86_fp80 @exp_f80(x86_fp80 %x) #0 {
 ; GISEL-X64-NEXT:    subq $24, %rsp
 ; GISEL-X64-NEXT:    fldt {{[0-9]+}}(%rsp)
 ; GISEL-X64-NEXT:    fstpt (%rsp)
-; GISEL-X64-NEXT:    callq expl@PLT
+; GISEL-X64-NEXT:    callq expl
 ; GISEL-X64-NEXT:    addq $24, %rsp
 ; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf x86_fp80 @llvm.exp.f80(x86_fp80 %x)
@@ -139,15 +150,18 @@ define float @exp2_f32(float %x) #0 {
 ; GISEL-X86-LABEL: exp2_f32:
 ; GISEL-X86:       # %bb.0:
 ; GISEL-X86-NEXT:    subl $12, %esp
-; GISEL-X86-NEXT:    flds {{[0-9]+}}(%esp)
-; GISEL-X86-NEXT:    fstps (%esp)
+; GISEL-X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT:    movl %eax, (%esp)
 ; GISEL-X86-NEXT:    calll exp2f
 ; GISEL-X86-NEXT:    addl $12, %esp
 ; GISEL-X86-NEXT:    retl
 ;
 ; GISEL-X64-LABEL: exp2_f32:
 ; GISEL-X64:       # %bb.0:
-; GISEL-X64-NEXT:    jmp exp2f@PLT # TAILCALL
+; GISEL-X64-NEXT:    pushq %rax
+; GISEL-X64-NEXT:    callq exp2f
+; GISEL-X64-NEXT:    popq %rax
+; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf float @llvm.exp2.f32(float %x)
   ret float %r
 }
@@ -168,15 +182,23 @@ define double @exp2_f64(double %x) #0 {
 ; GISEL-X86-LABEL: exp2_f64:
 ; GISEL-X86:       # %bb.0:
 ; GISEL-X86-NEXT:    subl $12, %esp
-; GISEL-X86-NEXT:    fldl {{[0-9]+}}(%esp)
-; GISEL-X86-NEXT:    fstpl (%esp)
+; GISEL-X86-NEXT:    leal {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
+; GISEL-X86-NEXT:    movl 4(%eax), %eax
+; GISEL-X86-NEXT:    xorl %edx, %edx
+; GISEL-X86-NEXT:    addl %esp, %edx
+; GISEL-X86-NEXT:    movl %ecx, (%esp)
+; GISEL-X86-NEXT:    movl %eax, 4(%edx)
 ; GISEL-X86-NEXT:    calll exp2
 ; GISEL-X86-NEXT:    addl $12, %esp
 ; GISEL-X86-NEXT:    retl
 ;
 ; GISEL-X64-LABEL: exp2_f64:
 ; GISEL-X64:       # %bb.0:
-; GISEL-X64-NEXT:    jmp exp2@PLT # TAILCALL
+; GISEL-X64-NEXT:    pushq %rax
+; GISEL-X64-NEXT:    callq exp2
+; GISEL-X64-NEXT:    popq %rax
+; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf double @llvm.exp2.f64(double %x)
   ret double %r
 }
@@ -231,7 +253,7 @@ define x86_fp80 @exp2_f80(x86_fp80 %x) #0 {
 ; GISEL-X64-NEXT:    subq $24, %rsp
 ; GISEL-X64-NEXT:    fldt {{[0-9]+}}(%rsp)
 ; GISEL-X64-NEXT:    fstpt (%rsp)
-; GISEL-X64-NEXT:    callq exp2l@PLT
+; GISEL-X64-NEXT:    callq exp2l
 ; GISEL-X64-NEXT:    addq $24, %rsp
 ; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf x86_fp80 @llvm.exp2.f80(x86_fp80 %x)
@@ -254,15 +276,18 @@ define float @log_f32(float %x) #0 {
 ; GISEL-X86-LABEL: log_f32:
 ; GISEL-X86:       # %bb.0:
 ; GISEL-X86-NEXT:    subl $12, %esp
-; GISEL-X86-NEXT:    flds {{[0-9]+}}(%esp)
-; GISEL-X86-NEXT:    fstps (%esp)
+; GISEL-X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT:    movl %eax, (%esp)
 ; GISEL-X86-NEXT:    calll logf
 ; GISEL-X86-NEXT:    addl $12, %esp
 ; GISEL-X86-NEXT:    retl
 ;
 ; GISEL-X64-LABEL: log_f32:
 ; GISEL-X64:       # %bb.0:
-; GISEL-X64-NEXT:    jmp logf@PLT # TAILCALL
+; GISEL-X64-NEXT:    pushq %rax
+; GISEL-X64-NEXT:    callq logf
+; GISEL-X64-NEXT:    popq %rax
+; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf float @llvm.log.f32(float %x)
   ret float %r
 }
@@ -283,15 +308,23 @@ define double @log_f64(double %x) #0 {
 ; GISEL-X86-LABEL: log_f64:
 ; GISEL-X86:       # %bb.0:
 ; GISEL-X86-NEXT:    subl $12, %esp
-; GISEL-X86-NEXT:    fldl {{[0-9]+}}(%esp)
-; GISEL-X86-NEXT:    fstpl (%esp)
+; GISEL-X86-NEXT:    leal {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
+; GISEL-X86-NEXT:    movl 4(%eax), %eax
+; GISEL-X86-NEXT:    xorl %edx, %edx
+; GISEL-X86-NEXT:    addl %esp, %edx
+; GISEL-X86-NEXT:    movl %ecx, (%esp)
+; GISEL-X86-NEXT:    movl %eax, 4(%edx)
 ; GISEL-X86-NEXT:    calll log
 ; GISEL-X86-NEXT:    addl $12, %esp
 ; GISEL-X86-NEXT:    retl
 ;
 ; GISEL-X64-LABEL: log_f64:
 ; GISEL-X64:       # %bb.0:
-; GISEL-X64-NEXT:    jmp log@PLT # TAILCALL
+; GISEL-X64-NEXT:    pushq %rax
+; GISEL-X64-NEXT:    callq log
+; GISEL-X64-NEXT:    popq %rax
+; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf double @llvm.log.f64(double %x)
   ret double %r
 }
@@ -346,7 +379,7 @@ define x86_fp80 @log_f80(x86_fp80 %x) #0 {
 ; GISEL-X64-NEXT:    subq $24, %rsp
 ; GISEL-X64-NEXT:    fldt {{[0-9]+}}(%rsp)
 ; GISEL-X64-NEXT:    fstpt (%rsp)
-; GISEL-X64-NEXT:    callq logl@PLT
+; GISEL-X64-NEXT:    callq logl
 ; GISEL-X64-NEXT:    addq $24, %rsp
 ; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf x86_fp80 @llvm.log.f80(x86_fp80 %x)
@@ -369,15 +402,18 @@ define float @log2_f32(float %x) #0 {
 ; GISEL-X86-LABEL: log2_f32:
 ; GISEL-X86:       # %bb.0:
 ; GISEL-X86-NEXT:    subl $12, %esp
-; GISEL-X86-NEXT:    flds {{[0-9]+}}(%esp)
-; GISEL-X86-NEXT:    fstps (%esp)
+; GISEL-X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT:    movl %eax, (%esp)
 ; GISEL-X86-NEXT:    calll log2f
 ; GISEL-X86-NEXT:    addl $12, %esp
 ; GISEL-X86-NEXT:    retl
 ;
 ; GISEL-X64-LABEL: log2_f32:
 ; GISEL-X64:       # %bb.0:
-; GISEL-X64-NEXT:    jmp log2f@PLT # TAILCALL
+; GISEL-X64-NEXT:    pushq %rax
+; GISEL-X64-NEXT:    callq log2f
+; GISEL-X64-NEXT:    popq %rax
+; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf float @llvm.log2.f32(float %x)
   ret float %r
 }
@@ -398,15 +434,23 @@ define double @log2_f64(double %x) #0 {
 ; GISEL-X86-LABEL: log2_f64:
 ; GISEL-X86:       # %bb.0:
 ; GISEL-X86-NEXT:    subl $12, %esp
-; GISEL-X86-NEXT:    fldl {{[0-9]+}}(%esp)
-; GISEL-X86-NEXT:    fstpl (%esp)
+; GISEL-X86-NEXT:    leal {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
+; GISEL-X86-NEXT:    movl 4(%eax), %eax
+; GISEL-X86-NEXT:    xorl %edx, %edx
+; GISEL-X86-NEXT:    addl %esp, %edx
+; GISEL-X86-NEXT:    movl %ecx, (%esp)
+; GISEL-X86-NEXT:    movl %eax, 4(%edx)
 ; GISEL-X86-NEXT:    calll log2
 ; GISEL-X86-NEXT:    addl $12, %esp
 ; GISEL-X86-NEXT:    retl
 ;
 ; GISEL-X64-LABEL: log2_f64:
 ; GISEL-X64:       # %bb.0:
-; GISEL-X64-NEXT:    jmp log2@PLT # TAILCALL
+; GISEL-X64-NEXT:    pushq %rax
+; GISEL-X64-NEXT:    callq log2
+; GISEL-X64-NEXT:    popq %rax
+; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf double @llvm.log2.f64(double %x)
   ret double %r
 }
@@ -461,7 +505,7 @@ define x86_fp80 @log2_f80(x86_fp80 %x) #0 {
 ; GISEL-X64-NEXT:    subq $24, %rsp
 ; GISEL-X64-NEXT:    fldt {{[0-9]+}}(%rsp)
 ; GISEL-X64-NEXT:    fstpt (%rsp)
-; GISEL-X64-NEXT:    callq log2l@PLT
+; GISEL-X64-NEXT:    callq log2l
 ; GISEL-X64-NEXT:    addq $24, %rsp
 ; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf x86_fp80 @llvm.log2.f80(x86_fp80 %x)
@@ -484,15 +528,18 @@ define float @log10_f32(float %x) #0 {
 ; GISEL-X86-LABEL: log10_f32:
 ; GISEL-X86:       # %bb.0:
 ; GISEL-X86-NEXT:    subl $12, %esp
-; GISEL-X86-NEXT:    flds {{[0-9]+}}(%esp)
-; GISEL-X86-NEXT:    fstps (%esp)
+; GISEL-X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT:    movl %eax, (%esp)
 ; GISEL-X86-NEXT:    calll log10f
 ; GISEL-X86-NEXT:    addl $12, %esp
 ; GISEL-X86-NEXT:    retl
 ;
 ; GISEL-X64-LABEL: log10_f32:
 ; GISEL-X64:       # %bb.0:
-; GISEL-X64-NEXT:    jmp log10f@PLT # TAILCALL
+; GISEL-X64-NEXT:    pushq %rax
+; GISEL-X64-NEXT:    callq log10f
+; GISEL-X64-NEXT:    popq %rax
+; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf float @llvm.log10.f32(float %x)
   ret float %r
 }
@@ -513,15 +560,23 @@ define double @log10_f64(double %x) #0 {
 ; GISEL-X86-LABEL: log10_f64:
 ; GISEL-X86:       # %bb.0:
 ; GISEL-X86-NEXT:    subl $12, %esp
-; GISEL-X86-NEXT:    fldl {{[0-9]+}}(%esp)
-; GISEL-X86-NEXT:    fstpl (%esp)
+; GISEL-X86-NEXT:    leal {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
+; GISEL-X86-NEXT:    movl 4(%eax), %eax
+; GISEL-X86-NEXT:    xorl %edx, %edx
+; GISEL-X86-NEXT:    addl %esp, %edx
+; GISEL-X86-NEXT:    movl %ecx, (%esp)
+; GISEL-X86-NEXT:    movl %eax, 4(%edx)
 ; GISEL-X86-NEXT:    calll log10
 ; GISEL-X86-NEXT:    addl $12, %esp
 ; GISEL-X86-NEXT:    retl
 ;
 ; GISEL-X64-LABEL: log10_f64:
 ; GISEL-X64:       # %bb.0:
-; GISEL-X64-NEXT:    jmp log10@PLT # TAILCALL
+; GISEL-X64-NEXT:    pushq %rax
+; GISEL-X64-NEXT:    callq log10
+; GISEL-X64-NEXT:    popq %rax
+; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf double @llvm.log10.f64(double %x)
   ret double %r
 }
@@ -576,7 +631,7 @@ define x86_fp80 @log10_f80(x86_fp80 %x) #0 {
 ; GISEL-X64-NEXT:    subq $24, %rsp
 ; GISEL-X64-NEXT:    fldt {{[0-9]+}}(%rsp)
 ; GISEL-X64-NEXT:    fstpt (%rsp)
-; GISEL-X64-NEXT:    callq log10l@PLT
+; GISEL-X64-NEXT:    callq log10l
 ; GISEL-X64-NEXT:    addq $24, %rsp
 ; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf x86_fp80 @llvm.log10.f80(x86_fp80 %x)
@@ -602,17 +657,20 @@ define float @pow_f32(float %x) #0 {
 ; GISEL-X86-LABEL: pow_f32:
 ; GISEL-X86:       # %bb.0:
 ; GISEL-X86-NEXT:    subl $12, %esp
-; GISEL-X86-NEXT:    flds {{[0-9]+}}(%esp)
-; GISEL-X86-NEXT:    fsts {{[0-9]+}}(%esp)
-; GISEL-X86-NEXT:    fstps (%esp)
+; GISEL-X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT:    movl %eax, (%esp)
+; GISEL-X86-NEXT:    movl %eax, {{[0-9]+}}(%esp)
 ; GISEL-X86-NEXT:    calll powf
 ; GISEL-X86-NEXT:    addl $12, %esp
 ; GISEL-X86-NEXT:    retl
 ;
 ; GISEL-X64-LABEL: pow_f32:
 ; GISEL-X64:       # %bb.0:
+; GISEL-X64-NEXT:    pushq %rax
 ; GISEL-X64-NEXT:    movaps %xmm0, %xmm1
-; GISEL-X64-NEXT:    jmp powf@PLT # TAILCALL
+; GISEL-X64-NEXT:    callq powf
+; GISEL-X64-NEXT:    popq %rax
+; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf float @llvm.pow.f32(float %x, float %x)
   ret float %r
 }
@@ -636,17 +694,28 @@ define double @pow_f64(double %x) #0 {
 ; GISEL-X86-LABEL: pow_f64:
 ; GISEL-X86:       # %bb.0:
 ; GISEL-X86-NEXT:    subl $28, %esp
-; GISEL-X86-NEXT:    fldl {{[0-9]+}}(%esp)
-; GISEL-X86-NEXT:    fstl {{[0-9]+}}(%esp)
-; GISEL-X86-NEXT:    fstpl (%esp)
+; GISEL-X86-NEXT:    leal {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
+; GISEL-X86-NEXT:    movl 4(%eax), %eax
+; GISEL-X86-NEXT:    xorl %edx, %edx
+; GISEL-X86-NEXT:    addl %esp, %edx
+; GISEL-X86-NEXT:    movl %ecx, (%esp)
+; GISEL-X86-NEXT:    movl %eax, 4(%edx)
+; GISEL-X86-NEXT:    movl $8, %edx
+; GISEL-X86-NEXT:    addl %esp, %edx
+; GISEL-X86-NEXT:    movl %ecx, {{[0-9]+}}(%esp)
+; GISEL-X86-NEXT:    movl %eax, 4(%edx)
 ; GISEL-X86-NEXT:    calll pow
 ; GISEL-X86-NEXT:    addl $28, %esp
 ; GISEL-X86-NEXT:    retl
 ;
 ; GISEL-X64-LABEL: pow_f64:
 ; GISEL-X64:       # %bb.0:
+; GISEL-X64-NEXT:    pushq %rax
 ; GISEL-X64-NEXT:    movaps %xmm0, %xmm1
-; GISEL-X64-NEXT:    jmp pow@PLT # TAILCALL
+; GISEL-X64-NEXT:    callq pow
+; GISEL-X64-NEXT:    popq %rax
+; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf double @llvm.pow.f64(double %x, double %x)
   ret double %r
 }
@@ -699,8 +768,8 @@ define x86_fp80 @pow_f80(x86_fp80 %x) #0 {
 ; GISEL-X86-NEXT:    subl $28, %esp
 ; GISEL-X86-NEXT:    fldt {{[0-9]+}}(%esp)
 ; GISEL-X86-NEXT:    fld %st(0)
-; GISEL-X86-NEXT:    fstpt {{[0-9]+}}(%esp)
 ; GISEL-X86-NEXT:    fstpt (%esp)
+; GISEL-X86-NEXT:    fstpt {{[0-9]+}}(%esp)
 ; GISEL-X86-NEXT:    calll powl
 ; GISEL-X86-NEXT:    addl $28, %esp
 ; GISEL-X86-NEXT:    retl
@@ -710,9 +779,9 @@ define x86_fp80 @pow_f80(x86_fp80 %x) #0 {
 ; GISEL-X64-NEXT:    subq $40, %rsp
 ; GISEL-X64-NEXT:    fldt {{[0-9]+}}(%rsp)
 ; GISEL-X64-NEXT:    fld %st(0)
-; GISEL-X64-NEXT:    fstpt {{[0-9]+}}(%rsp)
 ; GISEL-X64-NEXT:    fstpt (%rsp)
-; GISEL-X64-NEXT:    callq powl@PLT
+; GISEL-X64-NEXT:    fstpt {{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT:    callq powl
 ; GISEL-X64-NEXT:    addq $40, %rsp
 ; GISEL-X64-NEXT:    retq
   %r = tail call nnan ninf x86_fp80 @llvm.pow.f80(x86_fp80 %x, x86_fp80 %x)

@JaydeepChauhan14
Copy link
Contributor Author

@arsenm, @RKSimon, @e-kud please review PR.

@arsenm arsenm merged commit ab87206 into llvm:main Mar 8, 2025
11 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants