This is an archive of the discontinued LLVM Phabricator instance.

ValueLattice, LVI, SCCP: Use floating point constant ranges
Needs RevisionPublic

Authored by jvesely on Apr 15 2020, 11:23 AM.

Details

Reviewers
spatel
fhahn
nikic
Summary

This is enough to make existing tests pass, some with improved behaviour.

Diff Detail

Event Timeline

jvesely created this revision.Apr 15 2020, 11:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 15 2020, 11:23 AM

There were few issues in SCCP tests.

  • apint-load -- the result of the division operation of the original operands depends on rounding mode. it's represented as a range rather than a constant.
  • apint-ipsccp4 -- we can now deduce the starting range of v1 in ssa_copy intrinsic as [-Inf, 2.999] which then gets merged with more accurate information from the function call. The original behaviour started with unknown which then gets combined with more accurate information. Thus having less information at the beginning gives a better result. changing the comparison condition check to only allow Icmp works around the issue and keeps the old behaviour.
  • float-nan-simplification -- NaNs with different payloads/sign are not tracked separately, so one case returns +NaN while the other one returns -NaN. I've adjusted the comment in the test to explain the situation.

let me know what other tests you'd like me to add.

fhahn added a subscriber: fhahn.

Very interesting! On a high-level, it would probably be good to split those changes into 3 (ValueLattice, LVI & SCCP); not sure how tricky that's going to be given adding automatic support in markConstant & co. If it's too tricky splitting LVI & SCCP would be great.

Also, the existing tests cover very little floating point stuff, at least for SCCP (and probably LVI too), It would be good to add FP versions of llvm/tests/Transforms/{ip-ranges-binaryops.ll, ip-ranges-casts.ll, ip-ranges-select.ll ip-constant-ranges.ll, conditions-ranges.ll, conditions-ranges-with-undef.ll} for example.

Very interesting! On a high-level, it would probably be good to split those changes into 3 (ValueLattice, LVI & SCCP); not sure how tricky that's going to be given adding automatic support in markConstant & co. If it's too tricky splitting LVI & SCCP would be great.

the original implementation for llvm-10 split the changes in 3 patches. I wasn't able to cleanly do this in llvm 11, since changing value lattice to represent floats as ranges breaks sccp's assumptions that range is only used for int types.
splitting it would still mean changes in the other places to avoid crashes, and include test regressions. I can take another try.

Also, the existing tests cover very little floating point stuff, at least for SCCP (and probably LVI too), It would be good to add FP versions of llvm/tests/Transforms/{ip-ranges-binaryops.ll, ip-ranges-casts.ll, ip-ranges-select.ll ip-constant-ranges.ll, conditions-ranges.ll, conditions-ranges-with-undef.ll} for example.

thanks. I'll add those and update.

nikic added a reviewer: nikic.Apr 16 2020, 6:50 AM
fhahn requested changes to this revision.Mar 10 2021, 12:11 PM

I think there are outstanding comments and/or a rebase is needed. Marking as changes requested to clear up review queue.

This revision now requires changes to proceed.Mar 10 2021, 12:11 PM