Displaying 20 results from an estimated 118 matches for "int_min".
2015 Sep 10
3
[OpenCL] Implicit arithmetic conversion of INT_MIN to int vector type
Hello,
I recently came across an OpenCL kernel in which an int vector type was subtracted from the INT_MIN constant, e.g.
int2 v2 = INT_MIN - (int2)(0);
INT_MIN was defined as
#define INT_MIN (-2147483648)
Clang in OpenCL modes (-x cl) produces the following error:
vector_conversion.c:12:42: error: can't convert between vector values of different size ('long' and 'int2' (vector...
2014 Apr 25
2
[LLVMdev] Proposal: add intrinsics for safe division
..., 2014 at 10:19 AM, Filip Pizlo <fpizlo at apple.com> wrote:
The sdiv operation in LLVM IR only makes sense for C and its very direct relatives. The amount of control flow necessary to represent a safe division for any other language is ghastly. (a/b) becomes something like (b != 0 ? ((a != INT_MIN || b != -1) ? a / b : INT_MIN) : 0). It's more useful to the optimizer to see this as the single operation that it really is.
This argument makes sense to me. It would be hard for the arm64 backend to pattern match all this control flow back into a single instruction after optimizations.
Are...
2015 Jan 15
2
[LLVMdev] confusion w.r.t. scalar evolution and nuw
> We are permitted to turn 'sub nsw i32 %x, 1' into 'add nsw i32 %x, -1'
nsw also has the same problem:
sub nsw int_min, int_min is 0 but
add nsw int_min, (-int_min) is poison
-- Sanjoy
2014 Apr 25
4
[LLVMdev] Proposal: add intrinsics for safe division
...ent IR since any pass that
uses TTI in the IR level does the same.
The sdiv operation in LLVM IR only makes sense for C and its very direct relatives. The amount of control flow necessary to represent a safe division for any other language is ghastly. (a/b) becomes something like (b != 0 ? ((a != INT_MIN || b != -1) ? a / b : INT_MIN) : 0). It's more useful to the optimizer to see this as the single operation that it really is.
Also, this isn't about just a single target. Any target that has to emulate integer division (like a lot of embedded systems would do) would benefit from this sin...
2015 Oct 20
2
[compiler-rt] Undefined negation in float emulation functions
Hi,
I recently came across the following in __floatsidf in compiler-rt:
__floatsidf(int a) {
...
if (a < 0) {
...
a = -a;
In the case where a == INT_MIN, is this negation not undefined behaviour? AIUI this function is used for software
emulation on targets that have no hardware floating point support. Perhaps there is an in-built assumption that this
code is never called with INT_MIN, though I don't immediately see anything to indicate this....
2014 Jul 01
2
[LLVMdev] Probable error in InstCombine
I've found what appears to be a bug in instcombine. Specifically, the transformation of -(X/C) to X/(-C) is invalid if C == INT_MIN.
Specifically, if I have
> define i32 @foo(i32 %x) #0 {
> entry:
> %div = sdiv i32 %x, -2147483648
> %sub = sub nsw i32 0, %div
> ret i32 %sub
> }
then opt -instcombine will produce
> define i32 @foo(i32 %x) #0 {
> entry:
> %sub = sdiv i32 %x, -2147483648
> re...
2013 Oct 03
4
[LLVMdev] ScalarEvolution::createNodeForPHI
...ow to make sense of an NUW flag coming from a sub.
>
> NSW is just a misnomer for signed overflow. SCEV canonicalizes sub a,b to add a, (-b). Unfortunately, signed overflow is not the same thing for sub and add...
>
> sub nsw %a, %b != add nsw %a, (-1 * %b)
>
> sub nsw i32, -1, INT_MIN is true.
>
> add nsw i32, -1, (-1 * INT_MIN) is false.
>
> NSW flags just aren’t an effective way to tell SCEV about overflow. Ideally we could reason more generally about the loop’s undefined behavior. For example, I’d like to query the range of values that a variable can hold before...
2015 Oct 24
2
[compiler-rt] Undefined negation in float emulation functions
...expected);
return x != expected;
}
The printf suggests to me that the test should fail if `expected` is negative (which seems perfectly reasonable), but
the return statement does not include this condition. I tried to explore this a little, but it turns out calling
__absvisi2 with INT_MIN triggers compilerrt_abort(). Seems perfectly reasonable as abs(INT_MIN) is documented to be
undefined, however the call to compilerrt_abort sits behind this check:
const int N = (int)(sizeof(si_int) * CHAR_BIT);
if (a == (1 << (N-1)))
compilerrt_abort();
The shift in thi...
2014 Apr 25
3
[LLVMdev] Proposal: add intrinsics for safe division
..., 2014 at 10:19 AM, Filip Pizlo <fpizlo at apple.com> wrote:
The sdiv operation in LLVM IR only makes sense for C and its very direct relatives. The amount of control flow necessary to represent a safe division for any other language is ghastly. (a/b) becomes something like (b != 0 ? ((a != INT_MIN || b != -1) ? a / b : INT_MIN) : 0). It's more useful to the optimizer to see this as the single operation that it really is.
This argument makes sense to me. It would be hard for the arm64 backend to pattern match all this control flow back into a single instruction after optimizations.
I wa...
2017 Oct 20
1
Illegal Logical Values
I'm wondering if WRE Section 5.2 should be a little more explicit about misuse of integer values other than NA, 0, and 1 in LGLSXPs.? I'm thinking of this passage:
> Logical values are sent as 0 (FALSE), 1 (TRUE) or INT_MIN = -2147483648 (NA, but only if NAOK is true), and the compiled code should return one of these three values. (Non-zero values other than INT_MIN are mapped to TRUE.)
The parenthetical seems to suggest that something like 'LOGICAL(x)[0] = 2;' will be treated as TRUE, which it sometimes is,...
2013 Oct 03
0
[LLVMdev] ScalarEvolution::createNodeForPHI
...UW flag coming from a sub.
>>
>> NSW is just a misnomer for signed overflow. SCEV canonicalizes sub a,b to add a, (-b). Unfortunately, signed overflow is not the same thing for sub and add...
>>
>> sub nsw %a, %b != add nsw %a, (-1 * %b)
>>
>> sub nsw i32, -1, INT_MIN is true.
>>
>> add nsw i32, -1, (-1 * INT_MIN) is false.
>>
>> NSW flags just aren’t an effective way to tell SCEV about overflow. Ideally we could reason more generally about the loop’s undefined behavior. For example, I’d like to query the range of values that a variable...
2013 Oct 03
0
[LLVMdev] ScalarEvolution::createNodeForPHI
...n NUW flag coming from a sub.
>>
>> NSW is just a misnomer for signed overflow. SCEV canonicalizes sub a,b to add a, (-b). Unfortunately, signed overflow is not the same thing for sub and add...
>>
>> sub nsw %a, %b != add nsw %a, (-1 * %b)
>>
>> sub nsw i32, -1, INT_MIN is true.
>>
>> add nsw i32, -1, (-1 * INT_MIN) is false.
>>
>> NSW flags just aren’t an effective way to tell SCEV about overflow. Ideally we could reason more generally about the loop’s undefined behavior. For example, I’d like to query the range of values that a variable c...
2017 Oct 21
1
Illegal Logical Values
> On Fri, 2017-10-20 at 14:01 +0000, brodie gaslam via R-devel wrote:
> > I'm thinking of this passage:
> >
> > > Logical values are sent as 0 (FALSE), 1 (TRUE) or INT_MIN =
> > > -2147483648 (NA, but only if NAOK is true), and the compiled code
> > > should return one of these three values. (Non-zero values other
> > > than INT_MIN are mapped to TRUE.)
> >
> > The parenthetical seems to suggest that something like 'LOGICA...
2019 Sep 03
2
[ALTREP] What is the meaning of the return value of Is_sorted and No_NA function?
Hi,
I would like to figure out the meaning of the return value of these two
functions. Here are the default definitions I find from R source code:
static int altreal_Is_sorted_default(SEXP x) { return UNKNOWN_SORTEDNESS; }
static int altreal_No_NA_default(SEXP x) { return 0; }
I guess the macro *UNKNOWN_SORTEDNESS *in *Is_sorted* and 0 in *No_NA
*simply means
unknown sorted/NA status of
1998 Mar 03
1
":" (seq) bug -- should not always coerce to integer!
The problem seems that ":" always coerces to integer, but should not..
9.9:12
## R: [1] 9 10 11
## S-plus 3.4: [1] 9.9 10.9 11.9
## and many more examples....
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or
2013 Oct 02
0
[LLVMdev] ScalarEvolution::createNodeForPHI
...-----------//
I’m not sure how to make sense of an NUW flag coming from a sub.
NSW is just a misnomer for signed overflow. SCEV canonicalizes sub a,b to add a, (-b). Unfortunately, signed overflow is not the same thing for sub and add...
sub nsw %a, %b != add nsw %a, (-1 * %b)
sub nsw i32, -1, INT_MIN is true.
add nsw i32, -1, (-1 * INT_MIN) is false.
NSW flags just aren’t an effective way to tell SCEV about overflow. Ideally we could reason more generally about the loop’s undefined behavior. For example, I’d like to query the range of values that a variable can hold before the loop hits undef...
2013 Oct 03
2
[LLVMdev] ScalarEvolution::createNodeForPHI
...sub.
>>>
>>> NSW is just a misnomer for signed overflow. SCEV canonicalizes sub a,b to add a, (-b). Unfortunately, signed overflow is not the same thing for sub and add...
>>>
>>> sub nsw %a, %b != add nsw %a, (-1 * %b)
>>>
>>> sub nsw i32, -1, INT_MIN is true.
>>>
>>> add nsw i32, -1, (-1 * INT_MIN) is false.
>>>
>>> NSW flags just aren’t an effective way to tell SCEV about overflow. Ideally we could reason more generally about the loop’s undefined behavior. For example, I’d like to query the range of values t...
2014 May 02
3
[LLVMdev] Proposal: add intrinsics for safe division
On May 2, 2014, at 4:25 PM, Philip Reames <listmail at philipreames.com> wrote:
>
> I'm still not happy with hiding the explicit control flow, but I can achieve the same effect as:
> if( div by zero ) throw
> (r, o, d) = safe.div(a,b);
> if( o ) {
> r = a;
> }
>
> i.e. emit a separate guard branch for the interesting condition and not utilize the value
2017 Oct 03
2
Change in optimisation with UB in mind
Yes, the hairy-edges of undefined behaviour - UB is UB.
It does mean that given:
__attribute__((noinline)) int foo(int a, int b) { return a + b; }
int bar1(int x) { return foo(x, INT_MIN); }
int bar2(int x) { return x + INT_MIN; }
'bar1' and 'bar2' have different outcomes.
However, I think that the new optimisation is neat and valid and I am not suggesting that it should be changed, but it would be useful if a target could override this if they choose to do so....
2013 Oct 01
3
[LLVMdev] ScalarEvolution::createNodeForPHI
Hello to everybody,
I'm working on some improvements on trip count computation with ScalarEvolution
analysis.
Considering the following test
;----------------------------------------------------------------------------;
define void @foo(i32 %a, i32 %b, i32 %s) #0 {
entry:
%cmp = icmp sgt i32 %s, 0
%cmp15 = icmp sgt i32 %a, %b
%or.cond = and i1 %cmp, %cmp15
br i1 %or.cond, label