This is an archive of the discontinued LLVM Phabricator instance.

[NFC][SCEV] Changed the return type of some functions from ScalarEvolution
Needs RevisionPublic

Authored by dbakunevich on Mar 1 2023, 1:10 AM.

Details

Reviewers
mkazantsev
Summary

The getConstant function and related functions have their return type changed from SCEV to SCEVConstant. Within the semantics of the getConstant function, it is correct to return the SCEVConstant type. The same applies to the getZero, getOne, getMinusOne and getPowerOfTwo functions. For some files, I had to connect a ScalarEvolutionExpressions file. This is necessary for implicit casting from SCEVConstant to SCEV.

Diff Detail

Event Timeline

dbakunevich created this revision.Mar 1 2023, 1:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 1 2023, 1:10 AM
dbakunevich requested review of this revision.Mar 1 2023, 1:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 1 2023, 1:10 AM
mkazantsev added inline comments.Mar 1 2023, 2:36 AM
llvm/lib/Analysis/ScalarEvolution.cpp
489

cast

llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
63

????

mkazantsev added inline comments.Mar 1 2023, 2:38 AM
llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
63

Do I understand correctly that it's because auto resolve fails here?

dbakunevich marked 2 inline comments as done.
dbakunevich marked an inline comment as done.Mar 13 2023, 9:11 PM
dbakunevich added inline comments.
llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
63

Yes, you are right. I included this file so that automatic casting occurs.

mkazantsev requested changes to this revision.Mar 13 2023, 9:18 PM

Let's not do it. Making everyone include this header just because of this reason is an overkill.

This revision now requires changes to proceed.Mar 13 2023, 9:18 PM

Let's not do it. Making everyone include this header just because of this reason is an overkill.

Why is this overkill? The ScalarEvolutionExpression class contains a SCEVConstant class definition that defines the SCEVConstant class as inherit of the SCEV class. This information allows us to cast. Without connecting a class, it is impossible to make a cast.