-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[X86][NFC] - Add sitofp and fptosi tests for x87 mode #136860
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
[X86][NFC] - Add sitofp and fptosi tests for x87 mode #136860
Conversation
pawan-nirpal-031
commented
Apr 23, 2025
- Add global-isel runs as precommit testcases for sitofp and fptosi in x87 mode.
@llvm/pr-subscribers-backend-x86 Author: Pawan Nirpal (pawan-nirpal-031) Changes
Patch is 31.67 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/136860.diff 2 Files Affected:
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-- -...
[truncated]
|
; 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect that for precommit tests it should be abort=2
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
@@ -0,0 +1,272 @@ | |||
; 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename[isel-sint-to-fp-x87.ll ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@arsenm Ping for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one minor
|
||
; 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=2 | FileCheck %s --check-prefixes X64,GISEL-X64 | ||
; RUN: llc < %s -mtriple=i686-- -mattr=+x87,-sse,-sse2 -global-isel=0 | FileCheck %s --check-prefixes I686,SDAG-I686 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(pedantic) Please can we use X86 instead of I686?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, Sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
; 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=2 | FileCheck %s --check-prefixes X64,GISEL-X64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If none of these cases hit the fallback, it shouldn't be enabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this moment all cases hit the fallback to SDAG. In the next PR the support is going to be added, in this PR we change 2
to 1
illustrating which cases now are compiled completely by GlobalISel. Do you suggest to drop these lines as they in fact duplicate each other?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't matter if it's just going to be immediately changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we'll change it in the following patch