Skip to content
  • Ben Gamari's avatar
    94e197e3
    cmm: narrow when folding signed quotients · 94e197e3
    Ben Gamari authored
    Previously the constant-folding behavior for MO_S_Quot and MO_S_Rem
    failed to narrow its arguments, meaning that a program like:
    
        %zx64(%quot(%lobits8(0x00e1::bits16), 3::bits8))
    
    would be miscompiled. Specifically, this program should reduce as
    
                    %lobits8(0x00e1::bits16)                 == -31
              %quot(%lobits8(0x00e1::bits16), 3::bits8)      == -10
        %zx64(%quot(%lobits8(0x00e1::bits16), 3::bits8))     == 246
    
    However, with this bug the `%lobits8(0x00e1::bits16)` would instead
    be treated as `+31`, resulting in the incorrect result of `75`.
    94e197e3
    cmm: narrow when folding signed quotients
    Ben Gamari authored
    Previously the constant-folding behavior for MO_S_Quot and MO_S_Rem
    failed to narrow its arguments, meaning that a program like:
    
        %zx64(%quot(%lobits8(0x00e1::bits16), 3::bits8))
    
    would be miscompiled. Specifically, this program should reduce as
    
                    %lobits8(0x00e1::bits16)                 == -31
              %quot(%lobits8(0x00e1::bits16), 3::bits8)      == -10
        %zx64(%quot(%lobits8(0x00e1::bits16), 3::bits8))     == 246
    
    However, with this bug the `%lobits8(0x00e1::bits16)` would instead
    be treated as `+31`, resulting in the incorrect result of `75`.
Loading