This is an archive of the discontinued LLVM Phabricator instance.

[LoopUtils][SLPVectorizer] clean up management of fast-math-flags
ClosedPublic

Authored by spatel on May 22 2019, 3:57 PM.

Details

Summary

Instead of passing around fast-math-flags as a parameter, we can set those using an IRBuilder guard object. This is no-functional-change-intended, but hopefully someone more familiar with this code can try to confirm that.

The motivation is to eventually fix the vectorizers to use and set the correct fast-math-flags for reductions. Examples of that not behaving as expected are:
https://bugs.llvm.org/show_bug.cgi?id=23116 (should be able to reduce with less than 'fast')
https://bugs.llvm.org/show_bug.cgi?id=35538 (possible miscompile for -0.0)
D61802 (should be able to reduce with IR-level FMF)

Diff Detail

Event Timeline

spatel created this revision.May 22 2019, 3:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 22 2019, 3:57 PM
vporpo added inline comments.May 28 2019, 3:49 PM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
6298

If I am not mistaken, the flags are set to 'fast' by tryToReduce() line 6111. So maybe it is better to check them with an assert() ?

spatel marked an inline comment as done.Jun 4 2019, 6:45 AM
spatel added inline comments.
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
6298

Yes, that should be a good intermediate step until we can get this cleaned up properly.

spatel updated this revision to Diff 202929.Jun 4 2019, 6:47 AM

Patch updated:
Adjusted 'FIXME' comments and added an assert about 'fast' setting.

hfinkel accepted this revision.Jun 4 2019, 11:11 AM

LGTM. Seems like a reasonable intermediate step toward the desired state.

This revision is now accepted and ready to land.Jun 4 2019, 11:11 AM
This revision was automatically updated to reflect the committed changes.