From: Markus Trippelsdorf Date: Mon, 28 Nov 2016 18:33:19 +0000 (+0000) Subject: Fix PR78556 - left shift of negative values X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=82979abd860fb54c2d0ab0a1001d86ec69f71ae2;p=gcc.git Fix PR78556 - left shift of negative values Running bootstrap-ubsan on ppc64le shows many instances of e.g.: config/rs6000/rs6000.c:6217:36: runtime error: left shift of negative value -12301 PR target/78556 * config/rs6000/rs6000.c (vspltis_constant): Add casts to avoid left shifting of negative values. From-SVN: r242928 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ded59707617..41dcb5d6ca5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-11-28 Markus Trippelsdorf + + PR target/78556 + * config/rs6000/rs6000.c (vspltis_constant): Add casts to avoid + left shifting of negative values. + 2016-11-28 Jakub Jelinek PR fortran/78298 diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 6c28e6aaf65..dfb5dc86b11 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -6214,7 +6214,9 @@ vspltis_constant (rtx op, unsigned step, unsigned copies) bitsize /= 2; small_val = splat_val >> bitsize; mask >>= bitsize; - if (splat_val != ((small_val << bitsize) | (small_val & mask))) + if (splat_val != ((HOST_WIDE_INT) + ((unsigned HOST_WIDE_INT) small_val << bitsize) + | (small_val & mask))) return false; splat_val = small_val; }