• Keith Randall's avatar
    [dev.ssa] cmd/compile/internal/ssa: redo how sign extension is handled · 2a5e6c47
    Keith Randall authored
    For integer types less than a machine register, we have to decide
    what the invariants are for the high bits of the register.  We used
    to set the high bits to the correct extension (sign or zero, as
    determined by the type) of the low bits.
    
    This CL makes the compiler ignore the high bits of the register
    altogether (they are junk).
    
    On this plus side, this means ops that generate subword results don't
    have to worry about correctly extending them.  On the minus side,
    ops that consume subword arguments have to deal with the input
    registers not being correctly extended.
    
    For x86, this tradeoff is probably worth it.  Almost all opcodes
    have versions that use only the correct subword piece of their
    inputs.  (The one big exception is array indexing.)  Not many opcodes
    can correctly sign extend on output.
    
    For other architectures, the tradeoff is probably not so clear, as
    they don't have many subword-safe opcodes (e.g. 16-bit compare,
    ignoring the high 16/48 bits).  Fortunately we can decide whether
    we do this per-architecture.
    
    For the machine-independent opcodes, we pretend that the "register"
    size is equal to the type width, so sign extension is immaterial.
    Opcodes that care about the signedness of the input (e.g. compare,
    right shift) have two different variants.
    
    Change-Id: I465484c5734545ee697afe83bc8bf4b53bd9df8d
    Reviewed-on: https://go-review.googlesource.com/12600Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
    2a5e6c47
config.go 2.36 KB