This is an archive of the discontinued LLVM Phabricator instance.

Revert "[LoopVectorize] Simplify scalar cost calculation in getInstructionCost."
Needs ReviewPublic

Authored by fhahn on May 13 2022, 3:40 AM.

Details

Summary

This reverts 6998f8ae2d14e096aff33968f226587b5c1a193a.

Unfortunately another issue surfaced where the underlying assumption for
the patch does not hold and we hit the assertion for an Add instruction.

In pr55096-scalarize-add.ll, there's an add that will get scalarized (as
it is an induction update that has scalarized users) and there will be
multiple copies after vectorization.

The way we currently compute the costs for instructions involved in
induction updates is not really accurate, but I don't think there's an
easy way to ensure scalarized instructions will have single copy after
vectorization.

Fixes #55096.

Diff Detail

Event Timeline

fhahn created this revision.May 13 2022, 3:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2022, 3:40 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
fhahn requested review of this revision.May 13 2022, 3:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2022, 3:40 AM

Hi @fhahn, I think I remember when doing this patch these asserts were put in to deal with reviewer requests, but in my original patch I didn't have any asserts at all. I worry that reverting the patch doesn't solve the underlying problem, which is that the cost calculations are sometimes incorrect and difficult to follow. As a compromise could we just remove the assert, but keep the simpler (and easier to understand) logic? This patch has been in the codebase for over a year now without problems - personally it feels more appropriate to fix the assert rather than revert. What do you think?