This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine][WIP] Explicitly disable simplifyIntToPtrRoundTripCast for vectors.
AbandonedPublic

Authored by craig.topper on Dec 12 2022, 9:29 PM.

Details

Summary

This code compares getPointerTypeSizeInBits and getTypeSizeInBits.
getPointerTypeSizeInBits contains a call to getScalarType while
getTypeSizeInBits does not. This makes the code incorrect for vectors.

Additionally, for scalable vectors getTypeSizeInBits returns a scalable
TypeSize but getPointerTypeSizeInBits always returns an unsigned
integer. I believe the comparison forces the scalable TypeSize to
be converted to unsigned which triggers a warning.

Fixes PR59480.

Still need to add a test.

Diff Detail

Event Timeline

craig.topper created this revision.Dec 12 2022, 9:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 12 2022, 9:29 PM
craig.topper requested review of this revision.Dec 12 2022, 9:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 12 2022, 9:29 PM
pirama added a subscriber: pirama.Dec 12 2022, 11:07 PM
pirama added inline comments.
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
376

Would the control flow be clearer with:

if (CastTy->isVectorTy())
  return nullptr;
if (DL.get...)

?

377

Is the >> a tab or misalignment?

nikic added a subscriber: nikic.Dec 13 2022, 12:19 AM

Can't we just use getTypeSizeInBits() on both sides? ptrtoint/inttoptr can't change number of vector elements anyway.

craig.topper abandoned this revision.Dec 13 2022, 11:52 AM

Will post a new version with Nikita's suggestion.