This is an archive of the discontinued LLVM Phabricator instance.

Fold fcmp in cases where value is provably non-negative.
ClosedPublic

Authored by ArchDRobison on Jan 14 2015, 11:37 AM.

Details

Reviewers
reames
hfinkel
Summary

This patch folds fcmp in some cases of interest in Julia. The patch adds a function CannotBeOrderedLessThanZero that returns true if a value is provably not less than zero. I.e. the function returns true if the value is provably -0, +0, positive, or a NaN. The patch extends InstructionSimplify.cpp to fold instances of fcmp where:

  • the predicate is olt or uge
  • the first operand is provably not less than zero
  • the second operand is zero

The motivation for handling these cases optimizing away domain checks for sqrt in Julia for common idioms such as sqrt(x*x+y*y)..

  • Arch

Diff Detail

Event Timeline

ArchDRobison retitled this revision from to Fold fcmp in cases where value is provably non-negative. .
ArchDRobison updated this object.
ArchDRobison edited the test plan for this revision. (Show Details)
ArchDRobison added reviewers: reames, hfinkel.
ArchDRobison added a subscriber: Unknown Object (MLST).
reames edited edge metadata.Jan 26 2015, 2:49 PM

I see no obvious problems with this change, but am not comfortable enough to sign off. I'll defer to Hal or another interested reviewer.

hfinkel accepted this revision.Jan 27 2015, 5:41 AM
hfinkel edited edge metadata.

LGTM.

include/llvm/Analysis/ValueTracking.h
119

Line too long?

This revision is now accepted and ready to land.Jan 27 2015, 5:41 AM
ArchDRobison edited edge metadata.

Fixed excessively long line.

Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in rL227298.