Fix bug in optOptimizeBools for equality of 0/1.
authorChris McKinsey <chrismck@microsoft.com>
Fri, 26 Feb 2016 18:04:18 +0000 (10:04 -0800)
committerChris McKinsey <chrismck@microsoft.com>
Fri, 26 Feb 2016 18:16:47 +0000 (10:16 -0800)
commit0f5e6caf9d14f801feacfe40ce90b3836511ed90
tree51b40d6b6b4039220dc03aeb322a8f1171cab22e
parent017e9e205c9aa1356ef9573cefcb09bca99d5aba
Fix bug in optOptimizeBools for equality of 0/1.

The method optIsBoolCond had a clever way to test for a constant
of value 0/1 by casting the resulting gtIconVal to (unsigned) and
comparing for <= 1. Unfortunately, for 64-bit targets gtIconVal as
ssize_t holds 64-bits and the cast to (unsigned) results in truncating
significant bits and results in the optimization falsely recognizing
legal patterns of bit-tests comparing against 0/1. Because 32-bit
targets represent 64-bit long constants as GT_CNS_LNG they do not
suffer from this problem as the code already had exclusions for them.

Commit migrated from https://github.com/dotnet/coreclr/commit/fbdd95218427aa9be25aaa7730f10e4707404c71
src/coreclr/src/jit/optimizer.cpp
src/coreclr/tests/src/JIT/Regression/JitBlue/DevDiv_168744/DevDiv_168744.cs [new file with mode: 0644]
src/coreclr/tests/src/JIT/Regression/JitBlue/DevDiv_168744/DevDiv_168744.csproj [new file with mode: 0644]
src/coreclr/tests/src/JIT/Regression/JitBlue/DevDiv_168744/app.config [new file with mode: 0644]