1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=-sse -verify-machineinstrs < %s | FileCheck %s --check-prefix=X86
; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=-sse2 -verify-machineinstrs < %s | FileCheck %s --check-prefix=X86
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs < %s | FileCheck %s --check-prefix=X64
declare i32 @llvm.flt.rounds()
define i32 @test_flt_rounds() nounwind {
; X86-LABEL: test_flt_rounds:
; X86: # %bb.0:
; X86-NEXT: subl $2, %esp
; X86-NEXT: fnstcw (%esp)
; X86-NEXT: movzwl (%esp), %ecx
; X86-NEXT: shrl $9, %ecx
; X86-NEXT: andb $6, %cl
; X86-NEXT: movl $45, %eax
; X86-NEXT: # kill: def $cl killed $cl killed $ecx
; X86-NEXT: shrl %cl, %eax
; X86-NEXT: andl $3, %eax
; X86-NEXT: addl $2, %esp
; X86-NEXT: retl
;
; X64-LABEL: test_flt_rounds:
; X64: # %bb.0:
; X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
; X64-NEXT: movzwl -{{[0-9]+}}(%rsp), %ecx
; X64-NEXT: shrl $9, %ecx
; X64-NEXT: andb $6, %cl
; X64-NEXT: movl $45, %eax
; X64-NEXT: # kill: def $cl killed $cl killed $ecx
; X64-NEXT: shrl %cl, %eax
; X64-NEXT: andl $3, %eax
; X64-NEXT: retq
%1 = call i32 @llvm.flt.rounds()
ret i32 %1
}
; Make sure we preserve order with fesetround.
define i32 @multiple_flt_rounds() nounwind {
; X86-LABEL: multiple_flt_rounds:
; X86: # %bb.0: # %entry
; X86-NEXT: pushl %ebx
; X86-NEXT: pushl %esi
; X86-NEXT: subl $20, %esp
; X86-NEXT: movl $1024, (%esp) # imm = 0x400
; X86-NEXT: calll fesetround
; X86-NEXT: fnstcw {{[0-9]+}}(%esp)
; X86-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
; X86-NEXT: shrl $9, %ecx
; X86-NEXT: andb $6, %cl
; X86-NEXT: movl $45, %esi
; X86-NEXT: movl $45, %eax
; X86-NEXT: # kill: def $cl killed $cl killed $ecx
; X86-NEXT: shrl %cl, %eax
; X86-NEXT: andl $3, %eax
; X86-NEXT: xorl %ebx, %ebx
; X86-NEXT: cmpl $3, %eax
; X86-NEXT: setne %bl
; X86-NEXT: movl $0, (%esp)
; X86-NEXT: calll fesetround
; X86-NEXT: fnstcw {{[0-9]+}}(%esp)
; X86-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
; X86-NEXT: shrl $9, %ecx
; X86-NEXT: andb $6, %cl
; X86-NEXT: movl $45, %eax
; X86-NEXT: # kill: def $cl killed $cl killed $ecx
; X86-NEXT: shrl %cl, %eax
; X86-NEXT: andl $3, %eax
; X86-NEXT: cmpl $1, %eax
; X86-NEXT: je .LBB1_2
; X86-NEXT: # %bb.1: # %entry
; X86-NEXT: incl %ebx
; X86-NEXT: .LBB1_2: # %entry
; X86-NEXT: movl $3072, (%esp) # imm = 0xC00
; X86-NEXT: calll fesetround
; X86-NEXT: fnstcw {{[0-9]+}}(%esp)
; X86-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
; X86-NEXT: shrl $9, %ecx
; X86-NEXT: andb $6, %cl
; X86-NEXT: movl $45, %eax
; X86-NEXT: # kill: def $cl killed $cl killed $ecx
; X86-NEXT: shrl %cl, %eax
; X86-NEXT: andl $3, %eax
; X86-NEXT: cmpl $1, %eax
; X86-NEXT: sbbl $-1, %ebx
; X86-NEXT: movl $2048, (%esp) # imm = 0x800
; X86-NEXT: calll fesetround
; X86-NEXT: fnstcw {{[0-9]+}}(%esp)
; X86-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
; X86-NEXT: shrl $9, %ecx
; X86-NEXT: andb $6, %cl
; X86-NEXT: # kill: def $cl killed $cl killed $ecx
; X86-NEXT: shrl %cl, %esi
; X86-NEXT: andl $3, %esi
; X86-NEXT: xorl %ecx, %ecx
; X86-NEXT: cmpl $2, %esi
; X86-NEXT: setne %cl
; X86-NEXT: negl %ecx
; X86-NEXT: xorl %eax, %eax
; X86-NEXT: cmpl %ecx, %ebx
; X86-NEXT: setne %al
; X86-NEXT: addl $20, %esp
; X86-NEXT: popl %esi
; X86-NEXT: popl %ebx
; X86-NEXT: retl
;
; X64-LABEL: multiple_flt_rounds:
; X64: # %bb.0: # %entry
; X64-NEXT: pushq %rbp
; X64-NEXT: pushq %r14
; X64-NEXT: pushq %rbx
; X64-NEXT: subq $16, %rsp
; X64-NEXT: movl $1024, %edi # imm = 0x400
; X64-NEXT: callq fesetround
; X64-NEXT: fnstcw {{[0-9]+}}(%rsp)
; X64-NEXT: movzwl {{[0-9]+}}(%rsp), %ecx
; X64-NEXT: shrl $9, %ecx
; X64-NEXT: andb $6, %cl
; X64-NEXT: movl $45, %r14d
; X64-NEXT: movl $45, %eax
; X64-NEXT: # kill: def $cl killed $cl killed $ecx
; X64-NEXT: shrl %cl, %eax
; X64-NEXT: andl $3, %eax
; X64-NEXT: xorl %ebx, %ebx
; X64-NEXT: cmpl $3, %eax
; X64-NEXT: setne %bl
; X64-NEXT: xorl %edi, %edi
; X64-NEXT: callq fesetround
; X64-NEXT: fnstcw {{[0-9]+}}(%rsp)
; X64-NEXT: movzwl {{[0-9]+}}(%rsp), %ecx
; X64-NEXT: shrl $9, %ecx
; X64-NEXT: andb $6, %cl
; X64-NEXT: movl $45, %eax
; X64-NEXT: # kill: def $cl killed $cl killed $ecx
; X64-NEXT: shrl %cl, %eax
; X64-NEXT: andl $3, %eax
; X64-NEXT: leal 1(%rbx), %ebp
; X64-NEXT: cmpl $1, %eax
; X64-NEXT: cmovel %ebx, %ebp
; X64-NEXT: movl $3072, %edi # imm = 0xC00
; X64-NEXT: callq fesetround
; X64-NEXT: fnstcw {{[0-9]+}}(%rsp)
; X64-NEXT: movzwl {{[0-9]+}}(%rsp), %ecx
; X64-NEXT: shrl $9, %ecx
; X64-NEXT: andb $6, %cl
; X64-NEXT: movl $45, %eax
; X64-NEXT: # kill: def $cl killed $cl killed $ecx
; X64-NEXT: shrl %cl, %eax
; X64-NEXT: andl $3, %eax
; X64-NEXT: cmpl $1, %eax
; X64-NEXT: sbbl $-1, %ebp
; X64-NEXT: movl $2048, %edi # imm = 0x800
; X64-NEXT: callq fesetround
; X64-NEXT: fnstcw {{[0-9]+}}(%rsp)
; X64-NEXT: movzwl {{[0-9]+}}(%rsp), %ecx
; X64-NEXT: shrl $9, %ecx
; X64-NEXT: andb $6, %cl
; X64-NEXT: # kill: def $cl killed $cl killed $ecx
; X64-NEXT: shrl %cl, %r14d
; X64-NEXT: andl $3, %r14d
; X64-NEXT: xorl %ecx, %ecx
; X64-NEXT: cmpl $2, %r14d
; X64-NEXT: setne %cl
; X64-NEXT: negl %ecx
; X64-NEXT: xorl %eax, %eax
; X64-NEXT: cmpl %ecx, %ebp
; X64-NEXT: setne %al
; X64-NEXT: addq $16, %rsp
; X64-NEXT: popq %rbx
; X64-NEXT: popq %r14
; X64-NEXT: popq %rbp
; X64-NEXT: retq
entry:
%call = tail call i32 @fesetround(i32 1024)
%0 = tail call i32 @llvm.flt.rounds()
%cmp = icmp ne i32 %0, 3
%spec.select = zext i1 %cmp to i32
%call1 = tail call i32 @fesetround(i32 0)
%1 = tail call i32 @llvm.flt.rounds()
%cmp2 = icmp eq i32 %1, 1
%inc4 = select i1 %cmp, i32 2, i32 1
%errs.1 = select i1 %cmp2, i32 %spec.select, i32 %inc4
%call6 = tail call i32 @fesetround(i32 3072)
%2 = tail call i32 @llvm.flt.rounds()
%cmp7 = icmp ne i32 %2, 0
%inc9 = zext i1 %cmp7 to i32
%spec.select22 = add nuw nsw i32 %errs.1, %inc9
%call11 = tail call i32 @fesetround(i32 2048)
%3 = tail call i32 @llvm.flt.rounds()
%cmp12 = icmp ne i32 %3, 2
%inc14.neg = sext i1 %cmp12 to i32
%cmp16 = icmp ne i32 %spec.select22, %inc14.neg
%cond = zext i1 %cmp16 to i32
ret i32 %cond
}
; Function Attrs: nounwind
declare dso_local i32 @fesetround(i32) local_unnamed_addr #1
|