Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

Commit 59510c4

Browse files
fooishbartstellar
authored andcommitted
libclc: Fix rounding during type conversion
The rounding during type conversion uses multiple conversions, selecting between them to try to discover if rounding occurred. This appears to not have been tested, since it would generate code of the form: float convert_float_rtp(char x) { float r = convert_float(x); char y = convert_char(y); [...] } which will access uninitialised data. The idea appears to have been to have done a char -> float -> char roundtrip in order to discover the rounding, so do this. Discovered by inspection. Signed-off-by: Daniel Stone <[email protected]> Reviewed By: jvesely Differential Revision: https://reviews.llvm.org/D81999
1 parent 9b0f292 commit 59510c4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libclc/generic/lib/gen_convert.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def generate_float_conversion(src, dst, size, mode, sat):
355355
print(" return convert_{DST}{N}(x);".format(DST=dst, N=size))
356356
else:
357357
print(" {DST}{N} r = convert_{DST}{N}(x);".format(DST=dst, N=size))
358-
print(" {SRC}{N} y = convert_{SRC}{N}(y);".format(SRC=src, N=size))
358+
print(" {SRC}{N} y = convert_{SRC}{N}(r);".format(SRC=src, N=size))
359359
if mode == '_rtz':
360360
if src in int_types:
361361
print(" {USRC}{N} abs_x = abs(x);".format(USRC=unsigned_type[src], N=size))

0 commit comments

Comments
 (0)