mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-10 02:25:47 +00:00
It is possible to have code that converts from integer to float, performs operations then converts back, and the result is provably the same as if integers were used. This can come from different sources, but the most obvious is a helper function that uses floats but the arguments given at an inlined callsites are integers. This pass considers all integers requiring a bitwidth less than or equal to the bitwidth of the mantissa of a floating point type (23 for floats, 52 for doubles) as exactly representable in floating point. To reduce the risk of harming efficient code, the pass only attempts to perform complete removal of inttofp/fptoint operations, not just move them around. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233062 91177308-0d34-0410-b5e6-96231b3b80d8
17 lines
524 B
LLVM
17 lines
524 B
LLVM
; RUN: opt < %s -float2int -float2int-max-integer-bw=256 -S | FileCheck %s
|
|
|
|
; CHECK-LABEL: @neg_toolarge
|
|
; CHECK: %1 = uitofp i80 %a to fp128
|
|
; CHECK: %2 = fadd fp128 %1, %1
|
|
; CHECK: %3 = fptoui fp128 %2 to i80
|
|
; CHECK: ret i80 %3
|
|
; fp128 has a 112-bit mantissa, which can hold an i80. But we only support
|
|
; up to i64, so it should fail (even though the max integer bitwidth is 256).
|
|
define i80 @neg_toolarge(i80 %a) {
|
|
%1 = uitofp i80 %a to fp128
|
|
%2 = fadd fp128 %1, %1
|
|
%3 = fptoui fp128 %2 to i80
|
|
ret i80 %3
|
|
}
|
|
|