This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] (X * Y) / Y --> X for relaxed floating-point ops
ClosedPublic

Authored by spatel on Jan 22 2018, 10:52 AM.

Details

Summary

This is the FP counterpart that was mentioned in PR35709:
https://bugs.llvm.org/show_bug.cgi?id=35709

I suspect we're missing other similar basic folds for FP reassociations.

Diff Detail

Event Timeline

spatel created this revision.Jan 22 2018, 10:52 AM
grandinj added inline comments.
lib/Analysis/InstructionSimplify.cpp
4300

for these kinds of identities, should we not be matching

(X * A * B * ....) / X

?

i.e. whereever we are searching inside a group, we should scan until we hit a non-associative operator or an operator of different precedence ?

spatel added inline comments.Jan 23 2018, 6:41 AM
lib/Analysis/InstructionSimplify.cpp
4300

It's correct that this patch is too simple to handle that case, but I don't think we want to add more non-constant-time transforms to instsimplify. We should let the reassociation pass handle the bigger jobs...of course, reassociation could handle this case too, but solving the simple cases here means that other passes that use instsimplify as an analysis (GVN, etc) become stronger.

This revision is now accepted and ready to land.Jan 29 2018, 1:40 PM
This revision was automatically updated to reflect the committed changes.