• Eric Holk's avatar
    Restrict range for int64_t to immediate conversions · ec772a4f
    Eric Holk authored
    The included test case illustrates the problem. It subtracts (16 << 27)
    from another number. The Machine Operator Reducer would replace the
    shift computation with 0x0000000080000000, and then change the subtract
    to an add of -(0x0000000080000000), which is 0xffffffff80000000.
    The instruction selector would determine that this value could be an
    immediate, because it fits in 32 bits, so it would select the lea
    instruction. Finally, the code generator would detect that the
    immediate was less than 0, flip the sign and replace the add with a
    subtract of 0x80000000. Because the x64 subtract instruction's
    immediate field is 32 bits, the processor would interpret this as
    0xffffffff80000000 instead of an unsigned value.
    
    This change fixes the issue by making the CanBeImmediate check
    explicitly compare against INT_MIN and INT_MAX. We disallow INT_MIN
    as an immediate precisely because we cannot tell 0x0000000080000000
    from 0xffffffff80000000 when truncated to 32 bits.
    
    Bug: chromium:711203
    Change-Id: Ie371b8ea290684a6bb723bae9c693a866f961850
    Reviewed-on: https://chromium-review.googlesource.com/482448
    Commit-Queue: Eric Holk <eholk@chromium.org>
    Reviewed-by: 's avatarMircea Trofin <mtrofin@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#44758}
    ec772a4f
Name
Last commit
Last update
benchmarks Loading commit data...
build_overrides Loading commit data...
docs Loading commit data...
gni Loading commit data...
gypfiles Loading commit data...
include Loading commit data...
infra Loading commit data...
samples Loading commit data...
src Loading commit data...
test Loading commit data...
testing Loading commit data...
third_party Loading commit data...
tools Loading commit data...
.clang-format Loading commit data...
.gitignore Loading commit data...
.gn Loading commit data...
.ycm_extra_conf.py Loading commit data...
AUTHORS Loading commit data...
BUILD.gn Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
ChangeLog Loading commit data...
DEPS Loading commit data...
LICENSE Loading commit data...
LICENSE.fdlibm Loading commit data...
LICENSE.strongtalk Loading commit data...
LICENSE.v8 Loading commit data...
LICENSE.valgrind Loading commit data...
Makefile Loading commit data...
Makefile.android Loading commit data...
OWNERS Loading commit data...
PRESUBMIT.py Loading commit data...
README.md Loading commit data...
WATCHLISTS Loading commit data...
codereview.settings Loading commit data...
snapshot_toolchain.gni Loading commit data...