This is an archive of the discontinued LLVM Phabricator instance.

DCE math library calls with a constant operand
ClosedPublic

Authored by efriedma on Oct 25 2016, 2:59 PM.

Details

Summary

On platforms which use -fmath-errno, math libcalls without any uses require some extra checks to figure out if they are actually dead.

Fixes https://llvm.org/bugs/show_bug.cgi?id=30464 .

Diff Detail

Repository
rL LLVM

Event Timeline

efriedma updated this revision to Diff 75798.Oct 25 2016, 2:59 PM
efriedma retitled this revision from to DCE math library calls with a constant operand.
efriedma updated this object.
efriedma added reviewers: scanon, majnemer.
efriedma set the repository for this revision to rL LLVM.
efriedma added subscribers: llvm-commits, davidxl, xur, hfinkel.
majnemer accepted this revision.Oct 25 2016, 3:07 PM
majnemer edited edge metadata.

LGTM, you could use an ImmutableCallSite if you wish.

This revision is now accepted and ready to land.Oct 25 2016, 3:07 PM
davidxl added inline comments.Oct 25 2016, 3:27 PM
lib/Analysis/ConstantFolding.cpp
1971 ↗(On Diff #75798)

There are lots of duplicated logic here with LibcallShinkWrap pass. I think the right way to do is let the later passes to clean up the dead calls. This can be done by pushing libcall shrinkwrap later in the pipeline.

efriedma added inline comments.Oct 25 2016, 4:00 PM
lib/Analysis/ConstantFolding.cpp
1971 ↗(On Diff #75798)

The case which I originally ran into involves pow(), and LibCallsShrinkWrap can't really deal with that effectively, as far as I can tell.

It's probably possible to refactor the logic for some of the other libcalls... but we want to perform the check in isInstructionTriviallyDead to get rid of dead calls as soon as possible, so they don't block other optimizations.

davidxl added inline comments.Oct 25 2016, 4:14 PM
lib/Analysis/ConstantFolding.cpp
1971 ↗(On Diff #75798)

Refactoring is ideal, but it may not be easy to do. Please add a comment here to point to the refactoring opportunity in the future.

This revision was automatically updated to reflect the committed changes.