Closed chrisseaton closed 2 years ago
@chrisseaton thanks for the report, Ill have a look.
https://github.com/oracle/graal/commit/39bbdedcaefbccb9369fbf2dab4cec5e88b446c9 adds support to float integer division nodes early on in the compilation pipeline if we know they can never trap. Additionally, we float all fixed div nodes during lowering under certain conditions and can gvn them as well if they have equal, non-constant inputs. Late in the compilation pipeline we can also fold them together again to remove the explicit check if we can perform the div by zero check implicitly.
Wow that's a huge commit to fix this. Thanks very much!
For example this Ruby code:
I'd expect
n % 5 == 0
andn % 3 == 0
to be calculated once each, but they aren't, as the nodes are fixed and so GVN fails. They needn't be fixed, as they can't divide-by-zero.@davleopo