search for: fptrunc

Displaying 20 results from an estimated 65 matches for "fptrunc".

2013 Mar 21
0
[LLVMdev] fptrunc and undefined results
Hi, The LangRef says this about fptrunc: "The ‘fptrunc‘ instruction truncates a value from a larger floating point type to a smaller floating point type. If the value cannot fit within the destination type, ty2, then the results are undefined." What does it mean for the value to "fit within the destination type"?...
2017 Mar 17
2
Instruction Combine Cast (fptrunc (floor x)) -> (floor (fptrunc x))
Hi, I have a test case would fail due to instruction combine cast from floor to floorf. double d = 1024.0 - 1.0 / 32768.0; extern double floor(double); extern float floorf(float); extern void abort(); int main() { float f1 = (float)floor(d); if ((int)f1 != 1023) abort (); return 0; } My question is: Is the transformation legal for this case? Thanks, Shiva
2017 Mar 17
2
Instruction Combine Cast (fptrunc (floor x)) -> (floor (fptrunc x))
> On Mar 17, 2017, at 06:31, Hal Finkel via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hi Shiva, > > Thanks for reporting this. It looks like a bug to me (from r292855). Can you file a bug report? Matt, can you fix this? > > -Hal https://reviews.llvm.org/D31107
2014 Jul 09
6
[LLVMdev] Help!!!!Help!!!! " LLVM ERROR: Cannot select: 0x9fc9680: i32 = fp32_to_fp16 0x9fc0750 [ID=16] " problem!!!!!!!!!!!!!!!!!!
    Thank you Kevin!!!    If I use fptrunc and bitcast realise NEON vcvtt ( I can sure, "fptrunc  double %tmp to float" is right, but "fptrunc float %tmp to half" is wrong). My target platform is MIPS.  The command as following: NEON:            vcvtt.f16.f32 s2, s0 llvm Code: %Vt_2 = load float* %VFP_s0, align 4 %Vt...
2015 Aug 21
2
The semantics of the fptrunc instruction with an example of incorrect optimisation
I've recently been looking at how to implement in LLVM IR the rounding of floating point values when casting using different rounding modes and I've hit some problems. It seems that when casting down floats to less precise types the ``fptrunc`` LLVM IR instruction is used. The LLVM language reference suggests that it just truncates the value (which would be equivalent to rounding towards zero) but this seems to be very misleading because on the target I'm using (x86_64) that **is not** what happens. Consider the following example i...
2008 Mar 11
1
[LLVMdev] Rounding Mode for fptrunc Instruction
Hi, What is the rounding mode for the fptrunc instruction? Round to zero? Round to nearest? Or undefined? Regards, Jon
2014 Jul 09
4
[LLVMdev] Help!!!!Help!!!! " LLVM ERROR: Cannot select: 0x9fc9680: i32 = fp32_to_fp16 0x9fc0750 [ID=16] " problem!!!!!!!!!!!!!!!!!!
On 07/09/2014 12:41 PM, Matt Arsenault wrote: > On 07/09/2014 03:30 PM, yalong at multicorewareinc.com wrote: >> Thank you Kevin!!! >> If I use fptrunc and bitcast realise NEON vcvtt ( I can sure, >> "fptrunc double %tmp to float" is right, but "fptrunc float %tmp to >> half" is wrong). My target platform is MIPS. The command as following: >> >> NEON: >> vcvtt.f16.f32 s2, s0 >> >> l...
2014 Jul 14
2
[LLVMdev] RFC: Do we still need @llvm.convert.to.fp16 and the reverse?
...stellard.net> wrote: > On Mon, Jul 14, 2014 at 01:08:54PM +0100, Tim Northover wrote: >> Hi all, >> >> What do people think of doing away with the @llvm.convert.to.fp16 and >> @llvm.convert.from.fp16 intrinsics, in favour of using "half" and >> fpext/fptrunc? [1] >> > > I am in favor of using fpext/fptrunc instead of the intrinsics. The problem with this is the half type assumes you have half registers. I came up with some ugly hack that involved forcing custom lowering to make half loads/stores work for R600, but it was much easier to...
2014 Jul 10
2
[LLVMdev] Help!!!!Help!!!! " LLVM ERROR: Cannot select: 0x9fc9680: i32 = fp32_to_fp16 0x9fc0750 [ID=16] " problem!!!!!!!!!!!!!!!!!!
...u] On Behalf Of yalong at multicorewareinc.com Sent: 09 July 2014 23:31 To: Kevin Qin Cc: llvmdev Subject: Re: [LLVMdev] Help!!!!Help!!!! " LLVM ERROR: Cannot select: 0x9fc9680: i32 = fp32_to_fp16 0x9fc0750 [ID=16] " problem!!!!!!!!!!!!!!!!!!       Thank you Kevin!!!     If I use fptrunc and bitcast realise NEON vcvtt ( I can sure, "fptrunc  double %tmp to float" is right, but "fptrunc float %tmp to half" is wrong). My target platform is MIPS.  The command as following:   NEON:             vcvtt.f16.f32 s2, s0 llvm Code: %Vt_2 = load float* %...
2008 Apr 01
3
[LLVMdev] Reference Manual Clarifications 2
The fptrunc instruction states "If the value cannot fit within the destination type, ty2, then the results are undefined." This is fine, but what about other floating-point operations that can overflow? For example, does 'mul double 1.0e300, 1.0e300' produce +infinity or is it undefined...
2014 Jul 09
2
[LLVMdev] Help!!!!Help!!!! " LLVM ERROR: Cannot select: 0x9fc9680: i32 = fp32_to_fp16 0x9fc0750 [ID=16] " problem!!!!!!!!!!!!!!!!!!
...9] 0x9fbea90: i32 = Register %vreg13999 [ORD=125114] [ID=1] 0x9fd9ea0: i32 = Constant<80> [ORD=125115] [ID=2] 0x9feaab0: i32 = undef [ORD=125117] [ID=4] In function: internal_function_69 Command exited with non-zero status 1 � � If I change the method, I use " %1 =�fptrunc float %0 �to half ", then " %2 = bitcast half %1 to i16", I meet samiliar problem, the log is following: LLVM ERROR: Cannot select: 0x9f554b0: ch = store 0x9d0f28c, 0x9f5d900, 0x9f54ba8, 0x9f54b20<ST2[FixedStack0](align=4), trunc to f16> [ID=52] 0x9f5d900: f32,ch = load 0x9f...
2008 Apr 01
0
[LLVMdev] Reference Manual Clarifications 2
On Mon, 31 Mar 2008, Jon Sargeant wrote: > The fptrunc instruction states "If the value cannot fit within the > destination type, ty2, then the results are undefined." This is fine, but > what about other floating-point operations that can overflow? For example, > does 'mul double 1.0e300, 1.0e300' produce +infinity or i...
2019 Dec 10
2
TypePromoteFloat loses intermediate rounding operations
...en truncates to half before assigning to x. Like this define dso_local void @foo() #0 !dbg !18 { %1 = load half, half* @y, align 2, !dbg !21 %2 = fpext half %1 to float, !dbg !21 %3 = load half, half* @z, align 2, !dbg !22 %4 = fpext half %3 to float, !dbg !22 %5 = fadd float %2, %4, !dbg !23 %6 = fptrunc float %5 to half, !dbg !21 store half %6, half* @x, align 2, !dbg !24 %7 = load half, half* @x, align 2, !dbg !25 %8 = fpext half %7 to float, !dbg !25 %9 = load half, half* @w, align 2, !dbg !26 %10 = fpext half %9 to float, !dbg !26 %11 = fadd float %8, %10, !dbg !27 %12 = fptrunc float %11 to ha...
2019 Feb 25
3
Why is there still ineffective code after -o3 optimization?
...ainDataInputCallbackdRd(double %input, double* dereferenceable(8) %o0) local_unnamed_addr #0 { entry: %input.addr = alloca double, align 8 %o0.addr = alloca double*, align 8 %ui = alloca i32, align 4 store double %input, double* %input.addr, align 8 %0 = fptoui double %input to i64 %1 = fptrunc double %input to float %2 = mul i64 %0, %0 %3 = fptrunc double %input to float %4 = mul i64 %0, %0 %5 = fsub float %3, %3 store double* %o0, double** %o0.addr %6 = and i64 %0, %0 %7 = fptoui float %3 to i1 %8 = ashr i1 %7, %7 store double* null, double** %o0.addr %9 = fptosi dou...
2014 Jul 14
5
[LLVMdev] RFC: Do we still need @llvm.convert.to.fp16 and the reverse?
Hi all, What do people think of doing away with the @llvm.convert.to.fp16 and @llvm.convert.from.fp16 intrinsics, in favour of using "half" and fpext/fptrunc? [1] It looks like those intrinsics originally date from before "half" actually existed in LLVM, and of course the backends have grown up assuming that's what Clang will produce, so we'd have to improve their support first. But the benefit would be a more uniform interface to thi...
2019 Dec 10
2
TypePromoteFloat loses intermediate rounding operations
...e dso_local void @foo() #0 !dbg !18 { > > %1 = load half, half* @y, align 2, !dbg !21 > > %2 = fpext half %1 to float, !dbg !21 > > %3 = load half, half* @z, align 2, !dbg !22 > > %4 = fpext half %3 to float, !dbg !22 > > %5 = fadd float %2, %4, !dbg !23 > > %6 = fptrunc float %5 to half, !dbg !21 > > store half %6, half* @x, align 2, !dbg !24 > > %7 = load half, half* @x, align 2, !dbg !25 > > %8 = fpext half %7 to float, !dbg !25 > > %9 = load half, half* @w, align 2, !dbg !26 > > %10 = fpext half %9 to float, !dbg !26 > > %11...
2014 Jul 10
2
[LLVMdev] Help!!!!Help!!!! " LLVM ERROR: Cannot select: 0x9fc9680: i32 = fp32_to_fp16 0x9fc0750 [ID=16] " problem!!!!!!!!!!!!!!!!!!
...t-half conversion SDNodes into library calls.   +  setOperationAction(ISD::FP16_TO_FP32, MVT::f32, Expand); +  setOperationAction(ISD::FP32_TO_FP16, MVT::i32, Expand);   (The MVT::i32 on the second rule is required because type i16 is promoted to i32).   If you then convert every occurrence of 'fptrunc' from float to half with calls to @llvm.convert.to.fp16, then you should be able to compile (hopefully) with no errors. That means, in your original example you would convert the following IR statement:   %Vt3_1 = fptrunc float %Vt_2 to half into   %Vt3_1 = call i16 @llvm.convert.to.fp16(float...
2008 Jun 03
2
[LLVMdev] Truncate float to int?
Newbie question here: what's the best way to truncate a float to a signed int? The fptosi instruction rounds, and the fptrunc instruction simply truncates from a large float type to a smaller float type. Mark
2011 Sep 08
1
[LLVMdev] [cfe-dev] Proposal: floating point accuracy metadata (OpenCL related)
...lt.addr, align 8 store float %x, float* %x.addr, align 4 store float %y, float* %y.addr, align 4 %tmp = load float* %x.addr, align 4 %conv = fpext float %tmp to double %tmp1 = load float* %y.addr, align 4 %conv2 = fpext float %tmp1 to double %div = fdiv double %conv, %conv2 %conv3 = fptrunc double %div to float %tmp4 = load float** %result.addr, align 8 store float %conv3, float* %tmp4 ret void } ----- With optimisations turned on: ----- define void @dpdiv(float* nocapture %result, float %x, float %y) nounwind uwtable { entry: %conv3 = fdiv float %x, %y store float %conv3,...
2008 Mar 31
7
[LLVMdev] Reference Manual Clarifications
Here is a patch containing all but one of the changes. I realized that the remainder/modulo discussion does indeed belongs to the srem instruction. The semantics of urem are obvious and need no further clarification. Best Regards, Jon 1572,1573c1572,1575 < notation (see below). Floating point constants must have a <a < href="#t_floating">floating point</a>