Fixes Valgrind failures and removes bitwise operations that don't provide any benefit. Valgrind failures reported by NAKAMURA Takumi. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171413 91177308-0d34-0410-b5e6-96231b3b80d8