mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 04:48:08 +02:00
softfloat: make sign bit an unsigned int
According to ubsan shifting an int32_t by 31 bits to the left is undefined
behavior. So just declare it as uint32_t.
Backport-to: 26.1
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
(cherry picked from commit b2aa92b523)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41402>
This commit is contained in:
parent
5d40635bc8
commit
7116d2fed0
2 changed files with 6 additions and 4 deletions
|
|
@ -3064,7 +3064,7 @@
|
|||
"description": "softfloat: make sign bit an unsigned int",
|
||||
"nominated": true,
|
||||
"nomination_type": 4,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null,
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ double _mesa_roundtozero_f64(int64_t s, int64_t e, int64_t m)
|
|||
* \brief Extracted from softfloat_roundPackToF32()
|
||||
*/
|
||||
static inline
|
||||
float _mesa_round_f32(int32_t s, int32_t e, int32_t m, bool rtz)
|
||||
float _mesa_round_f32(uint32_t s, int32_t e, int32_t m, bool rtz)
|
||||
{
|
||||
fi_type result;
|
||||
uint8_t round_increment = rtz ? 0 : 0x40;
|
||||
|
|
@ -1192,7 +1192,8 @@ _mesa_float_fma_rtz(float a, float b, float c)
|
|||
uint32_t c_flt_m = c_fi.u & 0x07fffff;
|
||||
uint32_t c_flt_e = (c_fi.u >> 23) & 0xff;
|
||||
uint32_t c_flt_s = (c_fi.u >> 31) & 0x1;
|
||||
int32_t s, e, m = 0;
|
||||
uint32_t s;
|
||||
int32_t e, m = 0;
|
||||
|
||||
c_flt_s ^= 0;
|
||||
s = a_flt_s ^ b_flt_s ^ 0;
|
||||
|
|
@ -1371,7 +1372,8 @@ _mesa_double_to_f32(double val, bool rtz)
|
|||
uint64_t flt_m = di.u & 0x0fffffffffffff;
|
||||
uint64_t flt_e = (di.u >> 52) & 0x7ff;
|
||||
uint64_t flt_s = (di.u >> 63) & 0x1;
|
||||
int32_t s, e, m = 0;
|
||||
uint32_t s;
|
||||
int32_t e, m = 0;
|
||||
|
||||
s = flt_s;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue