This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] remove flop from lerp patterns
ClosedPublic

Authored by spatel on Jul 25 2019, 4:00 PM.

Details

Summary

(Y * (1.0 - Z)) + (X * Z) -->
Y - (Y * Z) + (X * Z) -->
Y + Z * (X - Y)

This is part of solving:
https://bugs.llvm.org/show_bug.cgi?id=42716

Factoring eliminates an instruction, so that should be a good canonicalization. The potential conversion to FMA would be handled by the backend based on target capabilities.

Diff Detail

Repository
rL LLVM

Event Timeline

spatel created this revision.Jul 25 2019, 4:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 25 2019, 4:00 PM
lebedev.ri accepted this revision.Jul 25 2019, 4:25 PM

I'm not confident about the FP fast-math flags, but the match/transform looks good.

This revision is now accepted and ready to land.Jul 25 2019, 4:25 PM

I'm not confident about the FP fast-math flags, but the match/transform looks good.

The required 1 is 'reassoc' - it gives us the ability to rearrange terms however we want. We're also requiring 'nsz' to be safe on related factorizations, so I kept that here to be conservative. In practice, if we're allowed to 'reassoc', then we've been given license to go crazy with FP, so all of the other flags are likely in play too (aka 'fast').

This revision was automatically updated to reflect the committed changes.