summaryrefslogtreecommitdiffstats
path: root/libclc
diff options
context:
space:
mode:
authorAaron Watry <awatry@gmail.com>2015-09-15 03:56:21 +0000
committerAaron Watry <awatry@gmail.com>2015-09-15 03:56:21 +0000
commit43ee367d1ee47bac5db494838a80f74e5a53a206 (patch)
treece06ca5d68d33aa23e90a94dffb91b83fae53677 /libclc
parent676a58c9b2cd290dea5db3fd5a185654fae9511c (diff)
downloadbcm5719-llvm-43ee367d1ee47bac5db494838a80f74e5a53a206.tar.gz
bcm5719-llvm-43ee367d1ee47bac5db494838a80f74e5a53a206.zip
integer: Update integer limits to comply with spec
The values for the char/short/integer/long minimums were declared with their actual values, not the definitions from the CL spec (v1.1). As a result, (-2147483648) was actually being treated as a long by the compiler, not an int, which caused issues when trying to add/subtract that value from a vector. Update the definitions to use the values declared by the spec, and also add explicit casts for the char/short/int minimums so that the compiler actually treats them as shorts/chars. Without those casts, they actually end up stored as integers, and the compiler may end up storing the INT_MIN as a long. The compiler can sign extend the values if it needs to convert the char->short, short->int, or int->long v2: Add explicit cast for INT_MIN and fix some type-o's and wrapping in the commit message. Reported-by: Moritz Pflanzer <moritz.pflanzer14@imperial.ac.uk> CC: Moritz Pflanzer <moritz.pflanzer14@imperial.ac.uk> Reviewed-by: Tom Stellard <thomas.stellard@amd.com> Signed-off-by: Aaron Watry <awatry@gmail.com> llvm-svn: 247661
Diffstat (limited to 'libclc')
-rw-r--r--libclc/generic/include/clc/integer/definitions.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/libclc/generic/include/clc/integer/definitions.h b/libclc/generic/include/clc/integer/definitions.h
index a407974a0d4..89de232b539 100644
--- a/libclc/generic/include/clc/integer/definitions.h
+++ b/libclc/generic/include/clc/integer/definitions.h
@@ -1,14 +1,14 @@
#define CHAR_BIT 8
#define INT_MAX 2147483647
-#define INT_MIN -2147483648
+#define INT_MIN ((int)(-2147483647 - 1))
#define LONG_MAX 0x7fffffffffffffffL
-#define LONG_MIN -0x8000000000000000L
+#define LONG_MIN (-0x7fffffffffffffffL - 1)
+#define CHAR_MAX SCHAR_MAX
+#define CHAR_MIN SCHAR_MIN
#define SCHAR_MAX 127
-#define SCHAR_MIN -128
-#define CHAR_MAX 127
-#define CHAR_MIN -128
+#define SCHAR_MIN ((char)(-127 - 1))
#define SHRT_MAX 32767
-#define SHRT_MIN -32768
+#define SHRT_MIN ((short)(-32767 - 1))
#define UCHAR_MAX 255
#define USHRT_MAX 65535
#define UINT_MAX 0xffffffff
OpenPOWER on IntegriCloud