Displaying 20 results from an estimated 62 matches for "fptosi".
2016 Jan 22
2
fptosi undefined behaviour
Hi all,
Consider the following snippet, the aim of which is to convert a
double to a signed i16, returning 0 if not exactly representable:
define i16 @foo(double) {
top:
%1 = fptosi double %0 to i16
%2 = sitofp i16 %1 to double
%3 = fcmp une double %2, %0
%4 = select i1 %3, i16 0, i16 %1
ret i16 %4
}
Of course, if the value is out-of-range, the result of fptosi is
undefined. Nevertheless, the snippet works on x86 & x86_64, generating
what to me seems to be fairly...
2018 Nov 05
3
Safe fptoui/fptosi casts
Hi everyone!
The fptoui/fptosi instructions are currently specified to return a poison
value if the rounded-towards-zero floating point number cannot be
represented by the target integer type. The motivation for this behavior is
that overflowing float to int casts in C are undefined behavior.
However, many newer languages prefe...
2020 Sep 04
4
Misleading documentation on FP to integer conversion instructions?
If fptosi takes 0.9 -> 0, then that is not 'rounding' in any sense I'm
aware of (IEEE754 or otherwise).
Rounding (in the IEE754 sense) determines how a number is converted when it
is halfway between two
candidate results. (see round(), ceil(), floor()).
fptosi seems to model the behavior of...
2018 Nov 05
5
Safe fptoui/fptosi casts
...dent intrinsic or IR,
since this behavior is not actually particular to WebAssembly.
On Mon, Nov 5, 2018 at 2:37 PM Finkel, Hal J. via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
>
> On 11/05/2018 07:26 AM, Nikita Popov via llvm-dev wrote:
>
> Hi everyone!
>
> The fptoui/fptosi instructions are currently specified to return a poison
> value if the rounded-towards-zero floating point number cannot be
> represented by the target integer type. The motivation for this behavior is
> that overflowing float to int casts in C are undefined behavior.
>
> However, ma...
2020 Sep 04
2
Misleading documentation on FP to integer conversion instructions?
The LLVM IR reference manual states, for fptosi:
"The ‘fptosi’ instruction converts its floating-point
<http://llvm.org/docs/LangRef.html#t-floating> operand into the nearest
(rounding towards zero) signed integer value."
I interpreted this to mean that it rounds:
The nearest integer to 0.3 is 0.
The nearest integer to 0.9 is...
2011 Sep 22
2
[LLVMdev] Need help in converting int to double
On Thu, Sep 22, 2011 at 3:46 PM, sarath chandra <sarathcse19 at gmail.com>wrote:
> Hi James,
>
> First i converted the void * to int* and then did FPToSI...then did SHL...(
> because CreateShl only accepts integers... i pointer casted it to int64 type
> first)... Below is the code snippet....
>
>
> lhs = mBuilder.CreateStructGEP(firstArg, 0);
> lhs = mBuilder.CreateLoad(lhs);
> lhs = mBuilder.CreatePointerCast(lhs, Point...
2011 Sep 22
0
[LLVMdev] Need help in converting int to double
...i8*
%2 = bitcast i8* %1 to i64*
%3 = getelementptr %Value* %secondArg, i32 0 ; i8**
%4 = load i8** %3; i8*
%5 = bitcast i8* %4 to i64*
%6 = load i64* %2
%7 = load i64* %5
Then you call convertDoubleToInt64(). What does this actually do?
It's in trouble by this point because it needs to do a fptosi on a double operand, but you've got an i64 operand and you can't reinterpret-cast ints to floats in LLVM IR (AFAIK)
I can't see what your code is doing afterwards as it uses calls to helper functions that you haven't included.
The main point I'd raise is: if your value is stor...
2012 Jan 06
2
[LLVMdev] How to duplicate a CallInst
Hi,
I have the following piece of code:
%34 = fptosi float %33 to i32
%35 = call i32 @function(i32 %34) nounwind
I would like of know how can I duplicate the statement %35 ? , as follows:
%34 = fptosi float %33 to i32
%35 = call i32 @function(i32 %34) nounwind
*%36 = **call i32 @function(i32 %34) nounwind*
*
*
i.e, two instructions exactly equal....
2011 Sep 22
1
[LLVMdev] Need help in converting int to double
...8** %3; i8*****
>
> %5 = bitcast i8* %4 to i64*****
>
> ** **
>
> %6 = load i64* %2****
>
> %7 = load i64* %5****
>
> ** **
>
> Then you call convertDoubleToInt64(). What does this actually do?****
>
> It’s in trouble by this point because it needs to do a fptosi on a double
> operand, but you’ve got an i64 operand and you can’t reinterpret-cast ints
> to floats in LLVM IR (AFAIK)****
>
> ** **
>
> I can’t see what your code is doing afterwards as it uses calls to helper
> functions that you haven’t included.****
>
> ** **
>
&g...
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
2020 Sep 04
3
Misleading documentation on FP to integer conversion instructions?
> On Sep 4, 2020, at 2:40 PM, Neil Nelson via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
>> If fptosi takes 0.9 -> 0, then that is not 'rounding' in any sense I'm aware of (IEEE754 or otherwise).
>> Rounding (in the IEE754 sense) determines how a number is converted when it is halfway between two
>> candidate results. (see round(), ceil(), floor()).
Rounding in the IEE...
2009 Feb 11
2
[LLVMdev] Eliminate PHI for non-copyable registers
In my hardware there are two special registers cannot be copied but can only
be assigned and referenced (read) in the other instruction. They are
allocatable also.
br i1 %if_cond, label %then, label %else
then:
%x1 = fptosi float %y1 to i32
br label %endif
else:
%x2 = fptosi float %y2 to i32
br label %endif
endif:
%x3 = phi i32 [%x1, %then], [%x2, %else]
PNE::LowerAtomiPHINode() fails because TargetInstrInfo::copyRegToReg()
doesn't support the copy of this type of register.
Most registers of this hardwar...
2016 Jan 22
2
fptosi undefined behaviour
On 22 January 2016 at 12:20, Tom Stellard via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
>> 1) I realise this is a somewhat silly question, but is this still
>> acceptable "undefined behaviour"?
>
> Yes, it is.
I always thought these out-of-range instructions did produce an
"undef" rather than allowing fully-general undefined behaviour
(otherwise we
2011 Sep 22
3
[LLVMdev] Need help in converting int to double
Hi,
I'm pursuing M.Tech course. As a part of the project work i'm using
LLVM as back-end. My project area is "Enhancing the performance of V8
javascript engine using LLVM as a back-end".
Now i'm writing code for shift left(SHL) operator. I had my own Value
Structure .. it's like this
Struct Value
{
void *val ;
char type;
}
The "char type" holds
2008 Jun 03
0
[LLVMdev] Truncate float to int?
On Tue, Jun 3, 2008 at 11:32 AM, Mark Leone <markleone at gmail.com> wrote:
> 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.
fptosi is equivalent to a C cast from float to int.
-Eli
2009 Feb 12
0
[LLVMdev] Eliminate PHI for non-copyable registers
On Feb 11, 2009, at 4:07 AM, Alex wrote:
> In my hardware there are two special registers cannot be copied but
> can only be assigned and referenced (read) in the other instruction.
> They are allocatable also.
>
> br i1 %if_cond, label %then, label %else
> then:
> %x1 = fptosi float %y1 to i32
> br label %endif
> else:
> %x2 = fptosi float %y2 to i32
> br label %endif
> endif:
> %x3 = phi i32 [%x1, %then], [%x2, %else]
>
> PNE::LowerAtomiPHINode() fails because
> TargetInstrInfo::copyRegToReg() doesn't support the copy of this
&...
2018 Jan 09
0
[cfe-dev] Why is #pragma STDC FENV_ACCESS not supported?
...gt; X86 backend, which should take care of instruction scheduling issues, but
> we'd still need a mechanism to prevent constant folding optimizations and
> such.
>
> As for what you could begin work on, it should be a fairly
> straight-forward task to implement the intrinsics for fptosi, fptoui, fcmp,
> fptrunc, and fpext. That would be a gentle introduction. Beyond that, it
> would be very helpful to have some pathfinding work done to solidify
> exactly what the remaining shortcomings are. I have a patch somewhere
> (stale by now, but I could refresh it pretty easily)...
2018 Jan 09
2
[cfe-dev] Why is #pragma STDC FENV_ACCESS not supported?
...which should take care of instruction
> scheduling issues, but we'd still need a mechanism to prevent
> constant folding optimizations and such.
>
> As for what you could begin work on, it should be a fairly
> straight-forward task to implement the intrinsics for fptosi,
> fptoui, fcmp, fptrunc, and fpext. That would be a gentle
> introduction. Beyond that, it would be very helpful to have some
> pathfinding work done to solidify exactly what the remaining
> shortcomings are. I have a patch somewhere (stale by now, but I
> could...
2018 Jan 08
4
[cfe-dev] Why is #pragma STDC FENV_ACCESS not supported?
...ed register modeling to the X86 backend, which should take care of instruction scheduling issues, but we'd still need a mechanism to prevent constant folding optimizations and such.
As for what you could begin work on, it should be a fairly straight-forward task to implement the intrinsics for fptosi, fptoui, fcmp, fptrunc, and fpext. That would be a gentle introduction. Beyond that, it would be very helpful to have some pathfinding work done to solidify exactly what the remaining shortcomings are. I have a patch somewhere (stale by now, but I could refresh it pretty easily) that unconditionall...
2010 Sep 28
2
[LLVMdev] x86 rounding mode question
Hi,
Is there a recommended way to round to the nearest whole (x86 RC field of
FPU control = 00) ?
It appears an intentional truncation instruction is generated (if ms
disassembly is correct):
IRBuilder<>::CreateFPToSI
%1 = fptosi double %0 to i64
00370025 fisttp qword ptr [esp]
Thanks,
Bob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100928/42385881/attachment.html>