This is an archive of the discontinued LLVM Phabricator instance.

[Scalarizer] Fix for vector bitcasts of different element numbers
AbandonedPublic

Authored by uabelho on May 22 2023, 2:05 AM.

Details

Summary

[Scalarizer] Fix for vector bitcasts of different element numbers

When scalarizing bitcasts ScalarizerVisitor::visitBitCastInst divide the
input in three different cases:

  1. same number of elements before and after
  2. more elements after
  3. less elements after

For the first case there is no problem, but for 2) the code only really
worked if we had the case
<M x t1> -> <N*M x t2>
Similarly for 3), the code only made sense for
<N*M x t1> -> <M x t2>

So e.g. if we get a bitcast like
%bc94 = bitcast <6 x i64> %wide.vec to <8 x i48>, !dbg !157
ScalarizerVisitor::visitBitCastInst crashes with
opt: ../lib/IR/Instructions.cpp:3447: static llvm::CastInst *llvm::CastInst::Create(Instruction::CastOps, llvm::Value *, llvm::Type *, const llvm::Twine &, llvm::Instruction *): Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed.

With this patch, we now make the scalarizer just leave such a bitcast since
it's totally unclear what we should do with it anyway.

ScalarizerVisitor::visitBitCastInst already returned early for
non-FixedVectorType type vectors.

Diff Detail

Event Timeline

uabelho created this revision.May 22 2023, 2:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 22 2023, 2:05 AM
uabelho requested review of this revision.May 22 2023, 2:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 22 2023, 2:05 AM
uabelho abandoned this revision.Jun 14 2023, 12:26 AM

This doesn't seem to be needed anymore after https://reviews.llvm.org/D149842 .