This is an archive of the discontinued LLVM Phabricator instance.

Convert fcmp with 0.0 from casted integers to icmp
ClosedPublic

Authored by arsenm on Nov 24 2014, 2:57 PM.

Details

Summary

This is already handled in general when it is known the
conversion can't lose bits with smaller integer types
casted into wider floating point types.

This pattern happens somewhat often in GPU programs that cast
workitem intrinsics to float, which are often compared with 0.

Specifically handle the special case of compares with zero which
should also be known to not lose information. I had a more general
version of this which allows equality compares if the casted float is
exactly representable in the integer, but I'm not 100% confident that
is always correct.

Also fold cases that aren't integers to true / false.

Diff Detail

Event Timeline

arsenm updated this revision to Diff 16586.Nov 24 2014, 2:57 PM
arsenm retitled this revision from to Convert fcmp with 0.0 from casted integers to icmp .
arsenm updated this object.
arsenm edited the test plan for this revision. (Show Details)
arsenm added reviewers: hfinkel, scanon.
arsenm added a subscriber: Unknown Object (MLST).
resistor accepted this revision.Jan 5 2015, 11:01 PM
resistor added a reviewer: resistor.
resistor added a subscriber: resistor.

LGTM.

This revision is now accepted and ready to land.Jan 5 2015, 11:01 PM
arsenm closed this revision.Jan 6 2015, 7:52 AM

r225265