graal
graal copied to clipboard
[GR-35795] Graal should combine multiple exact integer arithmetic operations
Ruby code that uses exact integer arithmetic such as a + 1 + 1 will not be combined to a + 2. I guess it's because it thinks the two deoptimisations that you get on the two overflows are different so need different deoptimisation points? Both sides of the IntegerAddExactSplit actually eventually lead to the same DynamicDeoptimize node though!
0x122ad9afe: add eax, 1
;Comment 97: 14 BRANCH trueDestinationProbability: 0.0 condition: |of| trueDestination: B0 -> B13 falseDestination: B0 -> B1
0x122ad9b01: jo 0x122ad9bf5
;Comment 103: block B1 null
;Comment 103: 16 [] = LABEL numbPhis: 0 align: false label: ?
;Comment 103: 18 r10|DWORD = ADD rax|DWORD y: 1 size: DWORD
0x122ad9b07: mov r10d, eax
0x122ad9b0a: add r10d, 1
;Comment 110: 20 BRANCH trueDestinationProbability: 0.0 condition: |of| trueDestination: B1 -> B12 falseDestination: B1 -> B2
0x122ad9b0e: jo 0x122ad9bd7
;Comment 116: block B2 null
;Comment 116: 22 [] = LABEL numbPhis: 0 align: false label: ?
;Comment 116: 24 rax|DWORD = LEA [r10|DWORD + 128] size: DWORD
@eregon
Example code to repro:
def foo(a)
a + 1 + 1
end
loop do
foo(rand(256))
end
Same issue on CE and EE.
Hi, Thank you for reporting this, we will take a look into it and get back to you
The issue is tracked internally on GR--35795