This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] Fix wrong Equal predicate created in getAddRecForPhiWithCasts
ClosedPublic

Authored by dorit on Nov 30 2017, 1:43 AM.

Details

Summary

This came up during D38948:

CreateAddRecFromPHIWithCastsImpl() adds an IncrementNUSW overflow predicate which allows the PSCEV rewriter to rewrite this scev expression:
(zext i8 {0, + , (trunc i32 step to i8)} to i32)
into
{0, +, (sext i8 (trunc i32 step to i8) to i32)}

But then it adds the wrong Equal predicate:
%step == (zext i8 (trunc i32 %step to i8) to i32).
instead of:
%step == (sext i8 (trunc i32 %step to i8) to i32)

This is fixed here.

Diff Detail

Repository
rL LLVM

Event Timeline

dorit created this revision.Nov 30 2017, 1:43 AM
sanjoy accepted this revision.Dec 7 2017, 10:38 PM

lgtm with stylistic nits.

lib/Analysis/ScalarEvolution.cpp
4631 ↗(On Diff #124886)

How about reducing the capture list of this lambda so that we don't have both Signed and isSigned in scope?

Alternately, you could s/isSigned/CreateSignExtend/ (actually now that I think of it, I like this option better than the first option).

Finally, the LLVM convention is to start variable names with uppercase.

This revision is now accepted and ready to land.Dec 7 2017, 10:38 PM
This revision was automatically updated to reflect the committed changes.