Skip to content

Commit ddd9575

Browse files
committed
[VectorCombine] rearrange bailouts for load insert for efficiency; NFC
1 parent e06914b commit ddd9575

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,29 +92,28 @@ static void replaceValue(Value &Old, Value &New) {
9292
}
9393

9494
bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
95-
// Match insert of scalar load.
95+
// Match insert into fixed vector of scalar load.
96+
auto *Ty = dyn_cast<FixedVectorType>(I.getType());
9697
Value *Scalar;
97-
if (!match(&I, m_InsertElt(m_Undef(), m_Value(Scalar), m_ZeroInt())))
98+
if (!Ty || !match(&I, m_InsertElt(m_Undef(), m_Value(Scalar), m_ZeroInt())))
9899
return false;
99-
auto *Load = dyn_cast<LoadInst>(Scalar);
100-
Type *ScalarTy = Scalar->getType();
100+
101101
// Do not vectorize scalar load (widening) if atomic/volatile or under
102102
// asan/hwasan/memtag/tsan. The widened load may load data from dirty regions
103103
// or create data races non-existent in the source.
104+
auto *Load = dyn_cast<LoadInst>(Scalar);
104105
if (!Load || !Load->isSimple() ||
105106
Load->getFunction()->hasFnAttribute(Attribute::SanitizeMemTag) ||
106107
mustSuppressSpeculation(*Load))
107108
return false;
108-
auto *Ty = dyn_cast<FixedVectorType>(I.getType());
109-
if (!Ty)
110-
return false;
111109

112110
// TODO: Extend this to match GEP with constant offsets.
113111
Value *PtrOp = Load->getPointerOperand()->stripPointerCasts();
114112
assert(isa<PointerType>(PtrOp->getType()) && "Expected a pointer type");
115113

116-
unsigned MinVectorSize = TTI.getMinVectorRegisterBitWidth();
114+
Type *ScalarTy = Scalar->getType();
117115
uint64_t ScalarSize = ScalarTy->getPrimitiveSizeInBits();
116+
unsigned MinVectorSize = TTI.getMinVectorRegisterBitWidth();
118117
if (!ScalarSize || !MinVectorSize || MinVectorSize % ScalarSize != 0)
119118
return false;
120119

0 commit comments

Comments
 (0)