This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Teach buildFMulAdd to peek through fneg to find fmul.
ClosedPublic

Authored by craig.topper on Feb 20 2023, 9:50 PM.

Details

Summary

Allows us to handle expressions like -(a * b) + c

Based on the examples from D144366 that gcc seems to get.

Diff Detail

Event Timeline

craig.topper created this revision.Feb 20 2023, 9:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 20 2023, 9:50 PM
Herald added a subscriber: StephenFan. · View Herald Transcript
craig.topper requested review of this revision.Feb 20 2023, 9:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 20 2023, 9:50 PM
kpn added inline comments.Feb 21 2023, 7:12 AM
clang/lib/CodeGen/CGExprScalar.cpp
3738

If I'm reading this right it looks like the assert() wasn't needed before. Do we know why it was added in the first place?

craig.topper added inline comments.
clang/lib/CodeGen/CGExprScalar.cpp
3738

I don't. I've added @lhames who wrote the code originally, but's been 10 years.

lhames added inline comments.Feb 22 2023, 5:00 PM
clang/lib/CodeGen/CGExprScalar.cpp
3738

It was probably included as a guard rail during bringup (from memory we didn't have any patterns in LLVM that matched both negations) and was never removed. I think it should be fine to remove.

kpn accepted this revision.Feb 23 2023, 6:25 AM

LGTM.

This revision is now accepted and ready to land.Feb 23 2023, 6:25 AM
This revision was landed with ongoing or failed builds.Feb 23 2023, 9:06 AM
This revision was automatically updated to reflect the committed changes.