Fix ceil_log2(0) (PR 86644)
commitcc1dd160e7ac0499b860e3e20411749df04847a6
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 25 Jul 2018 08:41:35 +0000 (25 08:41 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 25 Jul 2018 08:41:35 +0000 (25 08:41 +0000)
tree9f721d74a8a88c9af1612dc3c67cdb9f9aa32b6b
parent0c413628c1240ab571416643d80f0cd3879b7dd1
Fix ceil_log2(0) (PR 86644)

This PR shows a pathological case in which we try SLP vectorisation on
dead code.  We record that 0 bits of the result are enough to satisfy
all users (which is true), and that led to precision being 0 in:

static unsigned int
vect_element_precision (unsigned int precision)
{
  precision = 1 << ceil_log2 (precision);
  return MAX (precision, BITS_PER_UNIT);
}

ceil_log2 (0) returned 64 rather than 0, leading to 1 << 64, which is UB.

2018-07-25  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
* hwint.c (ceil_log2): Fix comment.  Return 0 for 0.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@262961 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/hwint.c