This is an archive of the discontinued LLVM Phabricator instance.

[StrictFP][IPSCCP] Constant fold constrained intrinsics
ClosedPublic

Authored by kpn on Oct 21 2022, 9:42 AM.

Details

Summary

This teaches the SCCP Solver how to constant fold the constrained intrinsics. Constant folding appears to be just as good as D115737 but much, much lower in code change impact as suggested by nikic.

Diff Detail

Event Timeline

kpn created this revision.Oct 21 2022, 9:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2022, 9:42 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
kpn requested review of this revision.Oct 21 2022, 9:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2022, 9:42 AM
nikic added inline comments.Oct 21 2022, 11:24 AM
llvm/lib/Transforms/Utils/SCCPSolver.cpp
1195

I don't think we need to check for constrained intrinsics here, we can always skip these, as also done here: https://github.com/llvm/llvm-project/blob/de1e911f02a0b4369287c7d056efc94c3f5dc0cd/llvm/lib/Analysis/InstructionSimplify.cpp#L6299

kpn updated this revision to Diff 470166.Oct 24 2022, 8:17 AM

Update for review comments: allow folding for more than constrained intrinsics.

I left the check for metadata in the same style as the check for struct types two lines up. To my eyes is reads nicer that way, but that's just one person's opinion.

nikic accepted this revision.Oct 24 2022, 8:24 AM

LGTM

This revision is now accepted and ready to land.Oct 24 2022, 8:24 AM
This revision was landed with ongoing or failed builds.Oct 24 2022, 8:43 AM
This revision was automatically updated to reflect the committed changes.