This is an archive of the discontinued LLVM Phabricator instance.

Prototype BasicAA improvements for discussion on llvm-dev
AbandonedPublic

Authored by markus on Nov 30 2018, 1:55 AM.

Diff Detail

Event Timeline

markus created this revision.Nov 30 2018, 1:55 AM
lebedev.ri added inline comments.
lib/Analysis/BasicAliasAnalysis.cpp
1016

Constants should always have already been canonicalized to the RHS

aqjune added a subscriber: aqjune.Nov 30 2018, 2:51 AM

I think we need to check whether shl/mul has nsw flag.

For example, 'shl i16 1024, 10' and 'shl i16 1024, 11' are both 0, so we need to check whether they don't overflow.

markus added a comment.EditedNov 30 2018, 3:00 AM

I think we need to check whether shl/mul has nsw flag.

For example, 'shl i16 1024, 10' and 'shl i16 1024, 11' are both 0, so we need to check whether they don't overflow.

Right. For my input there is no nsw flag but I guess one could equally well require more assumes on %X e.g. that it is in interval [a,b] and for this range the shl does not overflow.

edit: Or maybe if those assumes were already present some other pass would already have set a nsw flag on on the shl.

markus updated this revision to Diff 176776.Dec 5 2018, 1:56 AM

Did some more experiments, trying to clean up the code and make it more generic.
Instead of only determining if X != 0 (which is clearly not sufficient) try to produce a value range for the variable and use that.

markus updated this revision to Diff 179820.Jan 2 2019, 12:44 AM

Could you add some tests to this?

markus abandoned this revision.Oct 15 2021, 6:17 AM