This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] fneg(X + C) --> -C - X
ClosedPublic

Authored by spatel on Jan 20 2020, 10:56 AM.

Details

Summary

This is 1 of the potential folds uncovered by extending D72521.

We don't seem to do this in the backend either (unless I'm not seeing some target-specific transform).

icc and gcc (appears to be target-specific) do this transform.

Diff Detail

Event Timeline

spatel created this revision.Jan 20 2020, 10:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2020, 10:57 AM
llvm/test/Transforms/InstCombine/fneg.ll
407

Nit: are lowercase variables the standard format for tests? I see that they're uppercase in the source comments.

This revision is now accepted and ready to land.Jan 21 2020, 8:21 AM
spatel marked an inline comment as done.Jan 21 2020, 10:42 AM
spatel added inline comments.
llvm/test/Transforms/InstCombine/fneg.ll
407

There's no official standard for tests, but most IR tests seem to use lowercase. There are even (or at least used to be) tests that mixed variables that only differed in case (%x and %X), but that's obviously not good for scripts or humans.

Source code has a standard:
http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly
(there was a recent proposal for changing variable names to be lowerCamel, but seems to have died?)

Usually, I just copy the code comment to the test file for easier grepping, so I'm not sure why I changed it here. :)
If anyone has a preference, I can update to it.

This revision was automatically updated to reflect the committed changes.