Displaying 20 results from an estimated 1000 matches similar to: "Misleading documentation on FP to integer conversion instructions?"
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 a C cast from float to int,
which truncates the fractional bits (as in trunc()).
Steve
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(),
2017 Mar 20
2
Is it a valid fp transformation?
I agree. There’s implementation-defined behavior on the conversion of (arg*58) to int, but that shouldn’t be at issue here. The transform of (float)x + 1 => (float)(x + 1) is bogus.
> On Mar 20, 2017, at 10:41 AM, Sanjay Patel via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
> Looks broken to me; I don't think there's UB in the original program.
>
> The fold in
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 prefer to have a float to integer cast that
is well-defined for all input
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.
2011 Sep 22
0
[LLVMdev] Need help in converting int to double
Hi Sarath,
It would have really helped if you had removed the commented out code and inlined the calls to your homemade helper functions before sending it...
You are doing this, in LLVM IR:
%0 = getelementptr %Value* %firstArg, i32 0 ; i8**
%1 = load i8** %0 ; 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*
2011 Sep 22
1
[LLVMdev] Need help in converting int to double
Yeah, that's the fault...got the answer...... Thanks James for the help...
Struggling with this for so many days.......
On Thu, Sep 22, 2011 at 4:02 PM, James Molloy <James.Molloy at arm.com> wrote:
> Hi Sarath,****
>
> ** **
>
> It would have really helped if you had removed the commented out code and
> inlined the calls to your homemade helper functions before
2018 Nov 05
5
Safe fptoui/fptosi casts
I would be interested in learning what the set of used semantics for
float-to-int conversion is. If the only two used are 1) undefined behavior
if unrepresentable and 2) saturate to int_{min,max} with NaN going to zero,
then I think it makes sense to expose both of those natively in the IR. If
the set is much larger, I think separate intrinsics for each behavior would
make sense. It would be nice
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.
Using clone, results in badref.
Moreover, how
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 =
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
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
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
2016 May 16
6
Working on FP SCEV Analysis
[+CC Andy]
Hi Elena,
I don't have any fundamental issues with teaching SCEV about floating
point types, but given this will be a major change, I think a high
level roadmap should be discussed on llvm-dev before we start
reviewing and committing changes.
Here are some issues that I think are worth discussing:
- Core motivation: why do we even care about optimizing floating
point
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
>
2018 Jan 09
0
[cfe-dev] Why is #pragma STDC FENV_ACCESS not supported?
On 8 January 2018 at 11:15, Kaylor, Andrew via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> Hi Kevin,
>
> Thanks for reaching out about this, and thanks especially for offering to
> help. I've had some other priorities that have prevented me from making
> progress on this recently.
>
> As far as I know, there is no support at all in clang for handling the
>
2018 Jan 09
2
[cfe-dev] Why is #pragma STDC FENV_ACCESS not supported?
On 01/08/2018 07:06 PM, Richard Smith via llvm-dev wrote:
> On 8 January 2018 at 11:15, Kaylor, Andrew via llvm-dev
> <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
>
> Hi Kevin,
>
> Thanks for reaching out about this, and thanks especially for
> offering to help. I've had some other priorities that have
> prevented
2017 Mar 20
2
Is it a valid fp transformation?
This C program produces different results with -O0 and -O3 optimization levels.
#include <stdio.h>
float test(unsigned int arg) {
return (float)((int)(arg * 58)) + 1;
}
int main() {
printf("%d\n", (int)test((unsigned int)-831710640));
}
O0 result is -994576896
O3 result is -994576832
It happens because LLVM (specifically instcombine) does the following transformation:
2018 Jan 09
0
[cfe-dev] Why is #pragma STDC FENV_ACCESS not supported?
On 8 Jan 2018 19:50, "Hal Finkel via cfe-dev" <cfe-dev at lists.llvm.org>
wrote:
On 01/08/2018 07:06 PM, Richard Smith via llvm-dev wrote:
On 8 January 2018 at 11:15, Kaylor, Andrew via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> Hi Kevin,
>
> Thanks for reaching out about this, and thanks especially for offering to
> help. I've had some other
2018 Jan 08
4
[cfe-dev] Why is #pragma STDC FENV_ACCESS not supported?
Hi Kevin,
Thanks for reaching out about this, and thanks especially for offering to help. I've had some other priorities that have prevented me from making progress on this recently.
As far as I know, there is no support at all in clang for handling the FENV_ACCESS pragma. I have a sample patch somewhere that I created to demonstrate how the front end would create the constrained intrinsics