Skip to content

Commit 9f8e9de

Browse files
committed
use std::gcd instead self code
1 parent 6460b8a commit 9f8e9de

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,6 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
205205
if (!canWidenLoad(Load, TTI))
206206
return false;
207207

208-
auto MaxCommonDivisor = [](int n) {
209-
if (n % 4 == 0)
210-
return 4;
211-
if (n % 2 == 0)
212-
return 2;
213-
else
214-
return 1;
215-
};
216-
217208
Type *ScalarTy = Scalar->getType();
218209
uint64_t ScalarSize = ScalarTy->getPrimitiveSizeInBits();
219210
unsigned MinVectorSize = TTI.getMinVectorRegisterBitWidth();
@@ -255,7 +246,7 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
255246
uint64_t OldScalarSizeInBytes = ScalarSizeInBytes;
256247
// Assign the greatest common divisor between UnalignedBytes and Offset to
257248
// ScalarSizeInBytes
258-
ScalarSizeInBytes = MaxCommonDivisor(UnalignedBytes);
249+
ScalarSizeInBytes = std::gcd(ScalarSizeInBytes, UnalignedBytes);
259250
ScalarSize = ScalarSizeInBytes * 8;
260251
VectorRange = OldScalarSizeInBytes / ScalarSizeInBytes;
261252
MinVecNumElts = MinVectorSize / ScalarSize;

0 commit comments

Comments
 (0)