[llvm] [X86][NFC] - Add sitofp and fptosi tests for x87 mode (PR #136860)
Pawan Nirpal via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 23 06:09:52 PDT 2025
https://github.com/pawan-nirpal-031 created https://github.com/llvm/llvm-project/pull/136860
- Add global-isel runs as precommit testcases for sitofp and fptosi in x87 mode.
>From dc41e6374ef413b548a8898853bca7ae8360275a Mon Sep 17 00:00:00 2001
From: Pawan Nirpal <pawan.anil.nirpal at intel.com>
Date: Wed, 23 Apr 2025 15:07:30 +0200
Subject: [PATCH] [X86][NFC] - Add sitofp and fptosi tests for x87 mode
---
llvm/test/CodeGen/X86/isel-fp-to-sint-x87.ll | 514 +++++++++++++++++++
llvm/test/CodeGen/X86/isel-int-to-fp-x87.ll | 367 +++++++++++++
2 files changed, 881 insertions(+)
create mode 100644 llvm/test/CodeGen/X86/isel-fp-to-sint-x87.ll
create mode 100644 llvm/test/CodeGen/X86/isel-int-to-fp-x87.ll
diff --git a/llvm/test/CodeGen/X86/isel-fp-to-sint-x87.ll b/llvm/test/CodeGen/X86/isel-fp-to-sint-x87.ll
new file mode 100644
index 0000000000000..7779722684206
--- /dev/null
+++ b/llvm/test/CodeGen/X86/isel-fp-to-sint-x87.ll
@@ -0,0 +1,514 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; NOTE: Fast Isel is not added because it does not support x87 stores.
+
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+x87,-sse,-sse2 -global-isel=0 | FileCheck %s --check-prefixes X64,SDAG-X64
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+x87,-sse,-sse2 -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes X64,GISEL-X64
+; RUN: llc < %s -mtriple=i686-linux-gnu -mattr=+x87,-sse,-sse2 -global-isel=0 | FileCheck %s --check-prefixes I686,SDAG-I686
+; RUN: llc < %s -mtriple=i686-linux-gnu -mattr=+x87,-sse,-sse2 -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes I686,GISEL-I686
+
+define i8 @test_float_to_int8(float %input) nounwind {
+; SDAG-X64-LABEL: test_float_to_int8:
+; SDAG-X64: # %bb.0: # %entry
+; SDAG-X64-NEXT: flds {{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; SDAG-X64-NEXT: orl $3072, %eax # imm = 0xC00
+; SDAG-X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fistps -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
+; SDAG-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: test_float_to_int8:
+; GISEL-X64: # %bb.0: # %entry
+; GISEL-X64-NEXT: flds {{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; GISEL-X64-NEXT: orl $3072, %eax # imm = 0xC00
+; GISEL-X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fistps -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; GISEL-X64-NEXT: # kill: def $al killed $al killed $ax
+; GISEL-X64-NEXT: retq
+;
+; SDAG-I686-LABEL: test_float_to_int8:
+; SDAG-I686: # %bb.0: # %entry
+; SDAG-I686-NEXT: subl $8, %esp
+; SDAG-I686-NEXT: flds {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fnstcw {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; SDAG-I686-NEXT: orl $3072, %eax # imm = 0xC00
+; SDAG-I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fistps {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; SDAG-I686-NEXT: addl $8, %esp
+; SDAG-I686-NEXT: retl
+;
+; GISEL-I686-LABEL: test_float_to_int8:
+; GISEL-I686: # %bb.0: # %entry
+; GISEL-I686-NEXT: subl $8, %esp
+; GISEL-I686-NEXT: flds {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: fnstcw {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; GISEL-I686-NEXT: orl $3072, %eax # imm = 0xC00
+; GISEL-I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: fistps {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; GISEL-I686-NEXT: # kill: def $al killed $al killed $ax
+; GISEL-I686-NEXT: addl $8, %esp
+; GISEL-I686-NEXT: retl
+entry:
+ %conv = fptosi float %input to i8
+ ret i8 %conv
+}
+
+define i8 @test_longdouble_to_int8(x86_fp80 %input) nounwind {
+; SDAG-X64-LABEL: test_longdouble_to_int8:
+; SDAG-X64: # %bb.0: # %entry
+; SDAG-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; SDAG-X64-NEXT: orl $3072, %eax # imm = 0xC00
+; SDAG-X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fistps -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
+; SDAG-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: test_longdouble_to_int8:
+; GISEL-X64: # %bb.0: # %entry
+; GISEL-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; GISEL-X64-NEXT: orl $3072, %eax # imm = 0xC00
+; GISEL-X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fistps -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; GISEL-X64-NEXT: # kill: def $al killed $al killed $ax
+; GISEL-X64-NEXT: retq
+;
+; SDAG-I686-LABEL: test_longdouble_to_int8:
+; SDAG-I686: # %bb.0: # %entry
+; SDAG-I686-NEXT: subl $8, %esp
+; SDAG-I686-NEXT: fldt {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fnstcw {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; SDAG-I686-NEXT: orl $3072, %eax # imm = 0xC00
+; SDAG-I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fistps {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; SDAG-I686-NEXT: addl $8, %esp
+; SDAG-I686-NEXT: retl
+;
+; GISEL-I686-LABEL: test_longdouble_to_int8:
+; GISEL-I686: # %bb.0: # %entry
+; GISEL-I686-NEXT: subl $8, %esp
+; GISEL-I686-NEXT: fldt {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: fnstcw {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; GISEL-I686-NEXT: orl $3072, %eax # imm = 0xC00
+; GISEL-I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: fistps {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; GISEL-I686-NEXT: # kill: def $al killed $al killed $ax
+; GISEL-I686-NEXT: addl $8, %esp
+; GISEL-I686-NEXT: retl
+entry:
+ %conv = fptosi x86_fp80 %input to i8
+ ret i8 %conv
+}
+
+define i16 @test_float_to_int16(float %input) nounwind {
+; X64-LABEL: test_float_to_int16:
+; X64: # %bb.0: # %entry
+; X64-NEXT: flds {{[0-9]+}}(%rsp)
+; X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT: orl $3072, %eax # imm = 0xC00
+; X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: fistps -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT: retq
+;
+; I686-LABEL: test_float_to_int16:
+; I686: # %bb.0: # %entry
+; I686-NEXT: subl $8, %esp
+; I686-NEXT: flds {{[0-9]+}}(%esp)
+; I686-NEXT: fnstcw {{[0-9]+}}(%esp)
+; I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: orl $3072, %eax # imm = 0xC00
+; I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; I686-NEXT: fistps {{[0-9]+}}(%esp)
+; I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: addl $8, %esp
+; I686-NEXT: retl
+entry:
+ %conv = fptosi float %input to i16
+ ret i16 %conv
+}
+
+define i16 @test_longdouble_to_int16(x86_fp80 %input) nounwind {
+; X64-LABEL: test_longdouble_to_int16:
+; X64: # %bb.0: # %entry
+; X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT: orl $3072, %eax # imm = 0xC00
+; X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: fistps -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT: retq
+;
+; I686-LABEL: test_longdouble_to_int16:
+; I686: # %bb.0: # %entry
+; I686-NEXT: subl $8, %esp
+; I686-NEXT: fldt {{[0-9]+}}(%esp)
+; I686-NEXT: fnstcw {{[0-9]+}}(%esp)
+; I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: orl $3072, %eax # imm = 0xC00
+; I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; I686-NEXT: fistps {{[0-9]+}}(%esp)
+; I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: addl $8, %esp
+; I686-NEXT: retl
+entry:
+ %conv = fptosi x86_fp80 %input to i16
+ ret i16 %conv
+}
+
+define i32 @test_float_to_int32(float %input) nounwind {
+; X64-LABEL: test_float_to_int32:
+; X64: # %bb.0: # %entry
+; X64-NEXT: flds {{[0-9]+}}(%rsp)
+; X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT: orl $3072, %eax # imm = 0xC00
+; X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: fistpl -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT: retq
+;
+; I686-LABEL: test_float_to_int32:
+; I686: # %bb.0: # %entry
+; I686-NEXT: subl $8, %esp
+; I686-NEXT: flds {{[0-9]+}}(%esp)
+; I686-NEXT: fnstcw (%esp)
+; I686-NEXT: movzwl (%esp), %eax
+; I686-NEXT: orl $3072, %eax # imm = 0xC00
+; I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; I686-NEXT: fistpl {{[0-9]+}}(%esp)
+; I686-NEXT: fldcw (%esp)
+; I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: addl $8, %esp
+; I686-NEXT: retl
+entry:
+ %conv = fptosi float %input to i32
+ ret i32 %conv
+}
+
+define i32 @test_longdouble_to_int32(x86_fp80 %input) nounwind {
+; X64-LABEL: test_longdouble_to_int32:
+; X64: # %bb.0: # %entry
+; X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT: orl $3072, %eax # imm = 0xC00
+; X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: fistpl -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT: retq
+;
+; I686-LABEL: test_longdouble_to_int32:
+; I686: # %bb.0: # %entry
+; I686-NEXT: subl $8, %esp
+; I686-NEXT: fldt {{[0-9]+}}(%esp)
+; I686-NEXT: fnstcw (%esp)
+; I686-NEXT: movzwl (%esp), %eax
+; I686-NEXT: orl $3072, %eax # imm = 0xC00
+; I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; I686-NEXT: fistpl {{[0-9]+}}(%esp)
+; I686-NEXT: fldcw (%esp)
+; I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: addl $8, %esp
+; I686-NEXT: retl
+entry:
+ %conv = fptosi x86_fp80 %input to i32
+ ret i32 %conv
+}
+
+define i64 @test_float_to_int64(float %input) nounwind {
+; X64-LABEL: test_float_to_int64:
+; X64: # %bb.0: # %entry
+; X64-NEXT: flds {{[0-9]+}}(%rsp)
+; X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT: orl $3072, %eax # imm = 0xC00
+; X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: fistpll -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movq -{{[0-9]+}}(%rsp), %rax
+; X64-NEXT: retq
+;
+; SDAG-I686-LABEL: test_float_to_int64:
+; SDAG-I686: # %bb.0: # %entry
+; SDAG-I686-NEXT: subl $20, %esp
+; SDAG-I686-NEXT: flds {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fnstcw {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; SDAG-I686-NEXT: orl $3072, %eax # imm = 0xC00
+; SDAG-I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fistpll {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; SDAG-I686-NEXT: movl {{[0-9]+}}(%esp), %edx
+; SDAG-I686-NEXT: addl $20, %esp
+; SDAG-I686-NEXT: retl
+;
+; GISEL-I686-LABEL: test_float_to_int64:
+; GISEL-I686: # %bb.0: # %entry
+; GISEL-I686-NEXT: subl $20, %esp
+; GISEL-I686-NEXT: flds {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: leal {{[0-9]+}}(%esp), %ecx
+; GISEL-I686-NEXT: fnstcw {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; GISEL-I686-NEXT: orl $3072, %eax # imm = 0xC00
+; GISEL-I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: fistpll {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; GISEL-I686-NEXT: movl 4(%ecx), %edx
+; GISEL-I686-NEXT: addl $20, %esp
+; GISEL-I686-NEXT: retl
+entry:
+ %conv = fptosi float %input to i64
+ ret i64 %conv
+}
+
+define i64 @test_longdouble_to_int64(x86_fp80 %input) nounwind {
+; X64-LABEL: test_longdouble_to_int64:
+; X64: # %bb.0: # %entry
+; X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT: orl $3072, %eax # imm = 0xC00
+; X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: fistpll -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movq -{{[0-9]+}}(%rsp), %rax
+; X64-NEXT: retq
+;
+; SDAG-I686-LABEL: test_longdouble_to_int64:
+; SDAG-I686: # %bb.0: # %entry
+; SDAG-I686-NEXT: subl $20, %esp
+; SDAG-I686-NEXT: fldt {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fnstcw {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; SDAG-I686-NEXT: orl $3072, %eax # imm = 0xC00
+; SDAG-I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fistpll {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; SDAG-I686-NEXT: movl {{[0-9]+}}(%esp), %edx
+; SDAG-I686-NEXT: addl $20, %esp
+; SDAG-I686-NEXT: retl
+;
+; GISEL-I686-LABEL: test_longdouble_to_int64:
+; GISEL-I686: # %bb.0: # %entry
+; GISEL-I686-NEXT: subl $20, %esp
+; GISEL-I686-NEXT: fldt {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: leal {{[0-9]+}}(%esp), %ecx
+; GISEL-I686-NEXT: fnstcw {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; GISEL-I686-NEXT: orl $3072, %eax # imm = 0xC00
+; GISEL-I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: fistpll {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; GISEL-I686-NEXT: movl 4(%ecx), %edx
+; GISEL-I686-NEXT: addl $20, %esp
+; GISEL-I686-NEXT: retl
+entry:
+ %conv = fptosi x86_fp80 %input to i64
+ ret i64 %conv
+}
+
+define i8 @test_double_to_int8(double %input) nounwind {
+; SDAG-X64-LABEL: test_double_to_int8:
+; SDAG-X64: # %bb.0: # %entry
+; SDAG-X64-NEXT: fldl {{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; SDAG-X64-NEXT: orl $3072, %eax # imm = 0xC00
+; SDAG-X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fistps -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
+; SDAG-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: test_double_to_int8:
+; GISEL-X64: # %bb.0: # %entry
+; GISEL-X64-NEXT: fldl {{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; GISEL-X64-NEXT: orl $3072, %eax # imm = 0xC00
+; GISEL-X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fistps -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; GISEL-X64-NEXT: # kill: def $al killed $al killed $ax
+; GISEL-X64-NEXT: retq
+;
+; I686-LABEL: test_double_to_int8:
+; I686: # %bb.0: # %entry
+; I686-NEXT: subl $8, %esp
+; I686-NEXT: fldl {{[0-9]+}}(%esp)
+; I686-NEXT: fnstcw {{[0-9]+}}(%esp)
+; I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: orl $3072, %eax # imm = 0xC00
+; I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; I686-NEXT: fistps {{[0-9]+}}(%esp)
+; I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; I686-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: addl $8, %esp
+; I686-NEXT: retl
+entry:
+ %conv = fptosi double %input to i8
+ ret i8 %conv
+}
+
+define i16 @test_double_to_int16(double %input) nounwind {
+; X64-LABEL: test_double_to_int16:
+; X64: # %bb.0: # %entry
+; X64-NEXT: fldl {{[0-9]+}}(%rsp)
+; X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT: orl $3072, %eax # imm = 0xC00
+; X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: fistps -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT: retq
+;
+; I686-LABEL: test_double_to_int16:
+; I686: # %bb.0: # %entry
+; I686-NEXT: subl $8, %esp
+; I686-NEXT: fldl {{[0-9]+}}(%esp)
+; I686-NEXT: fnstcw {{[0-9]+}}(%esp)
+; I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: orl $3072, %eax # imm = 0xC00
+; I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; I686-NEXT: fistps {{[0-9]+}}(%esp)
+; I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: addl $8, %esp
+; I686-NEXT: retl
+entry:
+ %conv = fptosi double %input to i16
+ ret i16 %conv
+}
+
+define i32 @test_double_to_int32(double %input) nounwind {
+; X64-LABEL: test_double_to_int32:
+; X64: # %bb.0: # %entry
+; X64-NEXT: fldl {{[0-9]+}}(%rsp)
+; X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT: orl $3072, %eax # imm = 0xC00
+; X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: fistpl -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT: retq
+;
+; I686-LABEL: test_double_to_int32:
+; I686: # %bb.0: # %entry
+; I686-NEXT: subl $8, %esp
+; I686-NEXT: fldl {{[0-9]+}}(%esp)
+; I686-NEXT: fnstcw (%esp)
+; I686-NEXT: movzwl (%esp), %eax
+; I686-NEXT: orl $3072, %eax # imm = 0xC00
+; I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; I686-NEXT: fistpl {{[0-9]+}}(%esp)
+; I686-NEXT: fldcw (%esp)
+; I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: addl $8, %esp
+; I686-NEXT: retl
+entry:
+ %conv = fptosi double %input to i32
+ ret i32 %conv
+}
+
+define i64 @test_double_to_int64(double %input) nounwind {
+; X64-LABEL: test_double_to_int64:
+; X64: # %bb.0: # %entry
+; X64-NEXT: fldl {{[0-9]+}}(%rsp)
+; X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT: orl $3072, %eax # imm = 0xC00
+; X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: fistpll -{{[0-9]+}}(%rsp)
+; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT: movq -{{[0-9]+}}(%rsp), %rax
+; X64-NEXT: retq
+;
+; I686-LABEL: test_double_to_int64:
+; I686: # %bb.0: # %entry
+; I686-NEXT: subl $20, %esp
+; I686-NEXT: fldl {{[0-9]+}}(%esp)
+; I686-NEXT: fnstcw {{[0-9]+}}(%esp)
+; I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: orl $3072, %eax # imm = 0xC00
+; I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; I686-NEXT: fistpll {{[0-9]+}}(%esp)
+; I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: movl {{[0-9]+}}(%esp), %edx
+; I686-NEXT: addl $20, %esp
+; I686-NEXT: retl
+entry:
+ %conv = fptosi double %input to i64
+ ret i64 %conv
+}
diff --git a/llvm/test/CodeGen/X86/isel-int-to-fp-x87.ll b/llvm/test/CodeGen/X86/isel-int-to-fp-x87.ll
new file mode 100644
index 0000000000000..65eb3d8bbd401
--- /dev/null
+++ b/llvm/test/CodeGen/X86/isel-int-to-fp-x87.ll
@@ -0,0 +1,367 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; NOTE: Fast Isel is not added because it does not support x87 stores.
+
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+x87,-sse,-sse2 -global-isel=0 | FileCheck %s --check-prefixes X64,SDAG-X64
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+x87,-sse,-sse2 -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes X64,GISEL-X64
+; RUN: llc < %s -mtriple=i686-linux-gnu -mattr=+x87,-sse,-sse2 -global-isel=0 | FileCheck %s --check-prefixes I686,SDAG-I686
+; RUN: llc < %s -mtriple=i686-linux-gnu -mattr=+x87,-sse,-sse2 -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes I686,GISEL-I686
+
+define void @test_int8_to_float(i8 %x, ptr %p) nounwind {
+; SDAG-X64-LABEL: test_int8_to_float:
+; SDAG-X64: # %bb.0: # %entry
+; SDAG-X64-NEXT: movsbl %dil, %eax
+; SDAG-X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: filds -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fstps (%rsi)
+; SDAG-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: test_int8_to_float:
+; GISEL-X64: # %bb.0: # %entry
+; GISEL-X64-NEXT: shlw $8, %di
+; GISEL-X64-NEXT: sarw $8, %di
+; GISEL-X64-NEXT: movw %di, -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: filds -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fstps (%rsi)
+; GISEL-X64-NEXT: retq
+;
+; SDAG-I686-LABEL: test_int8_to_float:
+; SDAG-I686: # %bb.0: # %entry
+; SDAG-I686-NEXT: pushl %eax
+; SDAG-I686-NEXT: movsbl {{[0-9]+}}(%esp), %eax
+; SDAG-I686-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; SDAG-I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: filds {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fstps (%ecx)
+; SDAG-I686-NEXT: popl %eax
+; SDAG-I686-NEXT: retl
+;
+; GISEL-I686-LABEL: test_int8_to_float:
+; GISEL-I686: # %bb.0: # %entry
+; GISEL-I686-NEXT: pushl %eax
+; GISEL-I686-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; GISEL-I686-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; GISEL-I686-NEXT: shlw $8, %ax
+; GISEL-I686-NEXT: sarw $8, %ax
+; GISEL-I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: filds {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: fstps (%ecx)
+; GISEL-I686-NEXT: popl %eax
+; GISEL-I686-NEXT: retl
+entry:
+ %conv = sitofp i8 %x to float
+ store float %conv, ptr %p, align 4
+ ret void
+}
+
+define void @test_int16_to_float(i16 %x, ptr %p) nounwind {
+; X64-LABEL: test_int16_to_float:
+; X64: # %bb.0: # %entry
+; X64-NEXT: movw %di, -{{[0-9]+}}(%rsp)
+; X64-NEXT: filds -{{[0-9]+}}(%rsp)
+; X64-NEXT: fstps (%rsi)
+; X64-NEXT: retq
+;
+; SDAG-I686-LABEL: test_int16_to_float:
+; SDAG-I686: # %bb.0: # %entry
+; SDAG-I686-NEXT: pushl %eax
+; SDAG-I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; SDAG-I686-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
+; SDAG-I686-NEXT: movw %cx, {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: filds {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fstps (%eax)
+; SDAG-I686-NEXT: popl %eax
+; SDAG-I686-NEXT: retl
+;
+; GISEL-I686-LABEL: test_int16_to_float:
+; GISEL-I686: # %bb.0: # %entry
+; GISEL-I686-NEXT: pushl %eax
+; GISEL-I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; GISEL-I686-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; GISEL-I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: filds {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: fstps (%ecx)
+; GISEL-I686-NEXT: popl %eax
+; GISEL-I686-NEXT: retl
+entry:
+ %conv = sitofp i16 %x to float
+ store float %conv, ptr %p, align 4
+ ret void
+}
+
+define void @test_int32_to_float(i32 %x, ptr %p) nounwind {
+; X64-LABEL: test_int32_to_float:
+; X64: # %bb.0: # %entry
+; X64-NEXT: movl %edi, -{{[0-9]+}}(%rsp)
+; X64-NEXT: fildl -{{[0-9]+}}(%rsp)
+; X64-NEXT: fstps (%rsi)
+; X64-NEXT: retq
+;
+; SDAG-I686-LABEL: test_int32_to_float:
+; SDAG-I686: # %bb.0: # %entry
+; SDAG-I686-NEXT: pushl %eax
+; SDAG-I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; SDAG-I686-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; SDAG-I686-NEXT: movl %ecx, (%esp)
+; SDAG-I686-NEXT: fildl (%esp)
+; SDAG-I686-NEXT: fstps (%eax)
+; SDAG-I686-NEXT: popl %eax
+; SDAG-I686-NEXT: retl
+;
+; GISEL-I686-LABEL: test_int32_to_float:
+; GISEL-I686: # %bb.0: # %entry
+; GISEL-I686-NEXT: pushl %eax
+; GISEL-I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; GISEL-I686-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; GISEL-I686-NEXT: movl %eax, (%esp)
+; GISEL-I686-NEXT: fildl (%esp)
+; GISEL-I686-NEXT: fstps (%ecx)
+; GISEL-I686-NEXT: popl %eax
+; GISEL-I686-NEXT: retl
+entry:
+ %conv = sitofp i32 %x to float
+ store float %conv, ptr %p, align 4
+ ret void
+}
+
+define void @test_int64_to_float(i64 %x, ptr %p) nounwind {
+; X64-LABEL: test_int64_to_float:
+; X64: # %bb.0: # %entry
+; X64-NEXT: movq %rdi, -{{[0-9]+}}(%rsp)
+; X64-NEXT: fildll -{{[0-9]+}}(%rsp)
+; X64-NEXT: fstps (%rsi)
+; X64-NEXT: retq
+;
+; SDAG-I686-LABEL: test_int64_to_float:
+; SDAG-I686: # %bb.0: # %entry
+; SDAG-I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; SDAG-I686-NEXT: fildll {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: fstps (%eax)
+; SDAG-I686-NEXT: retl
+;
+; GISEL-I686-LABEL: test_int64_to_float:
+; GISEL-I686: # %bb.0: # %entry
+; GISEL-I686-NEXT: pushl %esi
+; GISEL-I686-NEXT: subl $8, %esp
+; GISEL-I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; GISEL-I686-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; GISEL-I686-NEXT: movl {{[0-9]+}}(%esp), %edx
+; GISEL-I686-NEXT: movl %esp, %esi
+; GISEL-I686-NEXT: movl %eax, (%esp)
+; GISEL-I686-NEXT: movl %ecx, 4(%esi)
+; GISEL-I686-NEXT: fildll (%esp)
+; GISEL-I686-NEXT: fstps (%edx)
+; GISEL-I686-NEXT: addl $8, %esp
+; GISEL-I686-NEXT: popl %esi
+; GISEL-I686-NEXT: retl
+entry:
+ %conv = sitofp i64 %x to float
+ store float %conv, ptr %p, align 4
+ ret void
+}
+
+define x86_fp80 @test_int8to_longdouble(i8 %a) nounwind {
+; SDAG-X64-LABEL: test_int8to_longdouble:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: movsbl %dil, %eax
+; SDAG-X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: filds -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: test_int8to_longdouble:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: shlw $8, %di
+; GISEL-X64-NEXT: sarw $8, %di
+; GISEL-X64-NEXT: movw %di, -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: filds -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: retq
+;
+; SDAG-I686-LABEL: test_int8to_longdouble:
+; SDAG-I686: # %bb.0:
+; SDAG-I686-NEXT: pushl %eax
+; SDAG-I686-NEXT: movsbl {{[0-9]+}}(%esp), %eax
+; SDAG-I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: filds {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: popl %eax
+; SDAG-I686-NEXT: retl
+;
+; GISEL-I686-LABEL: test_int8to_longdouble:
+; GISEL-I686: # %bb.0:
+; GISEL-I686-NEXT: pushl %eax
+; GISEL-I686-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; GISEL-I686-NEXT: shlw $8, %ax
+; GISEL-I686-NEXT: sarw $8, %ax
+; GISEL-I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: filds {{[0-9]+}}(%esp)
+; GISEL-I686-NEXT: popl %eax
+; GISEL-I686-NEXT: retl
+ %conv = sitofp i8 %a to x86_fp80
+ ret x86_fp80 %conv
+}
+
+define x86_fp80 @test_int16_to_longdouble(i16 %a) nounwind {
+; X64-LABEL: test_int16_to_longdouble:
+; X64: # %bb.0:
+; X64-NEXT: movw %di, -{{[0-9]+}}(%rsp)
+; X64-NEXT: filds -{{[0-9]+}}(%rsp)
+; X64-NEXT: retq
+;
+; I686-LABEL: test_int16_to_longdouble:
+; I686: # %bb.0:
+; I686-NEXT: pushl %eax
+; I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; I686-NEXT: filds {{[0-9]+}}(%esp)
+; I686-NEXT: popl %eax
+; I686-NEXT: retl
+ %conv = sitofp i16 %a to x86_fp80
+ ret x86_fp80 %conv
+}
+
+define x86_fp80 @test_int32_to_longdouble(i32 %a) nounwind {
+; X64-LABEL: test_int32_to_longdouble:
+; X64: # %bb.0:
+; X64-NEXT: movl %edi, -{{[0-9]+}}(%rsp)
+; X64-NEXT: fildl -{{[0-9]+}}(%rsp)
+; X64-NEXT: retq
+;
+; I686-LABEL: test_int32_to_longdouble:
+; I686: # %bb.0:
+; I686-NEXT: pushl %eax
+; I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: movl %eax, (%esp)
+; I686-NEXT: fildl (%esp)
+; I686-NEXT: popl %eax
+; I686-NEXT: retl
+ %conv = sitofp i32 %a to x86_fp80
+ ret x86_fp80 %conv
+}
+
+define x86_fp80 @test_int64_to_longdouble(i64 %a, ptr %p) nounwind {
+; X64-LABEL: test_int64_to_longdouble:
+; X64: # %bb.0:
+; X64-NEXT: movq %rdi, -{{[0-9]+}}(%rsp)
+; X64-NEXT: fildll -{{[0-9]+}}(%rsp)
+; X64-NEXT: retq
+;
+; SDAG-I686-LABEL: test_int64_to_longdouble:
+; SDAG-I686: # %bb.0:
+; SDAG-I686-NEXT: fildll {{[0-9]+}}(%esp)
+; SDAG-I686-NEXT: retl
+;
+; GISEL-I686-LABEL: test_int64_to_longdouble:
+; GISEL-I686: # %bb.0:
+; GISEL-I686-NEXT: subl $12, %esp
+; GISEL-I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; GISEL-I686-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; GISEL-I686-NEXT: movl %esp, %edx
+; GISEL-I686-NEXT: movl %eax, (%esp)
+; GISEL-I686-NEXT: movl %ecx, 4(%edx)
+; GISEL-I686-NEXT: fildll (%esp)
+; GISEL-I686-NEXT: addl $12, %esp
+; GISEL-I686-NEXT: retl
+ %conv = sitofp i64 %a to x86_fp80
+ ret x86_fp80 %conv
+}
+
+
+define void @test_int8to_double(i8 %x, ptr %p) nounwind {
+; SDAG-X64-LABEL: test_int8to_double:
+; SDAG-X64: # %bb.0: # %entry
+; SDAG-X64-NEXT: movsbl %dil, %eax
+; SDAG-X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: filds -{{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fstpl (%rsi)
+; SDAG-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: test_int8to_double:
+; GISEL-X64: # %bb.0: # %entry
+; GISEL-X64-NEXT: shlw $8, %di
+; GISEL-X64-NEXT: sarw $8, %di
+; GISEL-X64-NEXT: movw %di, -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: filds -{{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fstpl (%rsi)
+; GISEL-X64-NEXT: retq
+;
+; I686-LABEL: test_int8to_double:
+; I686: # %bb.0: # %entry
+; I686-NEXT: pushl %eax
+; I686-NEXT: movsbl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; I686-NEXT: filds {{[0-9]+}}(%esp)
+; I686-NEXT: fstpl (%ecx)
+; I686-NEXT: popl %eax
+; I686-NEXT: retl
+entry:
+ %conv = sitofp i8 %x to double
+ store double %conv, ptr %p, align 4
+ ret void
+}
+
+define void @test_int16_to_double(i16 %x, ptr %p) nounwind {
+; X64-LABEL: test_int16_to_double:
+; X64: # %bb.0: # %entry
+; X64-NEXT: movw %di, -{{[0-9]+}}(%rsp)
+; X64-NEXT: filds -{{[0-9]+}}(%rsp)
+; X64-NEXT: fstpl (%rsi)
+; X64-NEXT: retq
+;
+; I686-LABEL: test_int16_to_double:
+; I686: # %bb.0: # %entry
+; I686-NEXT: pushl %eax
+; I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
+; I686-NEXT: movw %cx, {{[0-9]+}}(%esp)
+; I686-NEXT: filds {{[0-9]+}}(%esp)
+; I686-NEXT: fstpl (%eax)
+; I686-NEXT: popl %eax
+; I686-NEXT: retl
+entry:
+ %conv = sitofp i16 %x to double
+ store double %conv, ptr %p, align 4
+ ret void
+}
+
+define void @test_int32_to_double(i32 %x, ptr %p) nounwind {
+; X64-LABEL: test_int32_to_double:
+; X64: # %bb.0: # %entry
+; X64-NEXT: movl %edi, -{{[0-9]+}}(%rsp)
+; X64-NEXT: fildl -{{[0-9]+}}(%rsp)
+; X64-NEXT: fstpl (%rsi)
+; X64-NEXT: retq
+;
+; I686-LABEL: test_int32_to_double:
+; I686: # %bb.0: # %entry
+; I686-NEXT: pushl %eax
+; I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; I686-NEXT: movl %ecx, (%esp)
+; I686-NEXT: fildl (%esp)
+; I686-NEXT: fstpl (%eax)
+; I686-NEXT: popl %eax
+; I686-NEXT: retl
+entry:
+ %conv = sitofp i32 %x to double
+ store double %conv, ptr %p, align 4
+ ret void
+}
+
+define void @test_int64_to_double(i64 %x, ptr %p) nounwind {
+; X64-LABEL: test_int64_to_double:
+; X64: # %bb.0: # %entry
+; X64-NEXT: movq %rdi, -{{[0-9]+}}(%rsp)
+; X64-NEXT: fildll -{{[0-9]+}}(%rsp)
+; X64-NEXT: fstpl (%rsi)
+; X64-NEXT: retq
+;
+; I686-LABEL: test_int64_to_double:
+; I686: # %bb.0: # %entry
+; I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; I686-NEXT: fildll {{[0-9]+}}(%esp)
+; I686-NEXT: fstpl (%eax)
+; I686-NEXT: retl
+entry:
+ %conv = sitofp i64 %x to double
+ store double %conv, ptr %p, align 4
+ ret void
+}
More information about the llvm-commits
mailing list