This is an archive of the discontinued LLVM Phabricator instance.

[IVDescriptor] Make sure the sign is included for negative extension.
ClosedPublic

Authored by fhahn on Nov 2 2021, 2:16 PM.

Details

Summary

At the moment, computeRecurrenceType does not include any sign bits in
the maximum bit width. If the value can be negative, this means the sign
bit will be missing and the sext won't properly extend the value.

If the value can be negative, increment the bitwidth by one to make sure
there is at least one sign bit in the result value.

Note that the increment is also needed *if* the value is *known* to be
negative, as a sign bit needs to be preserved for the sext to work.

Note that this at the moment prevents vectorization, because the
analysis computes i1 as type for the recurrence when looking through the
AND in lookThroughAnd.

Fixes PR51794, PR52485.

Diff Detail

Event Timeline

fhahn created this revision.Nov 2 2021, 2:16 PM
fhahn requested review of this revision.Nov 2 2021, 2:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 2 2021, 2:16 PM
fhahn added a comment.Nov 12 2021, 7:34 AM

Ping :)

should also fix PR51794

fhahn edited the summary of this revision. (Show Details)Nov 12 2021, 7:35 AM

Ping :)

should also fix PR51794

Should be PR52485....

Ping :)

should also fix PR51794

Should be PR52485....

Worth an extra test case?

fhahn updated this revision to Diff 386861.Nov 12 2021, 8:17 AM

Ping :)

should also fix PR51794

Should be PR52485....

Worth an extra test case?

Rebased on top of committed test from PR52485.

spatel accepted this revision.Nov 12 2021, 8:22 AM

LGTM

llvm/lib/Analysis/IVDescriptors.cpp
149–151

typo: "at at"

This revision is now accepted and ready to land.Nov 12 2021, 8:22 AM