[SDAG] Fix expansion of BITREVERSE
authorJames Molloy <james.molloy@arm.com>
Fri, 13 Nov 2015 10:02:36 +0000 (10:02 +0000)
committerJames Molloy <james.molloy@arm.com>
Fri, 13 Nov 2015 10:02:36 +0000 (10:02 +0000)
commit3808e8c85d0923c8adfb0645eed4fb0e595baaa8
treebc473db00e01185a6ce9a39636f2a756ce87a579
parent63f8155d9d57520dcb065c3f8cf4295911a877f9
[SDAG] Fix expansion of BITREVERSE

Richard Trieu noted that UBSan detected an overflowing shift, and the obvious fix caused a crash.

What was happening was that the shiftee (1U) was indeed too small for the possible range of shifts it had to handle, but also we were using "VT.getSizeInBits()" to get the maximum type bitwidth, but we wanted "VT.getScalarSizeInBits()" to get the vector lane size instead of the entire vector size.

Use an APInt for the shift and VT.getScalarSizeInBits().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253023 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
test/CodeGen/AArch64/bitreverse.ll