Skip to content

Commit 4860a87

Browse files
committed
use std::gcd instead self code
1 parent fbbec1d commit 4860a87

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
@@ -243,15 +243,6 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
243243
if (!canWidenLoad(Load, TTI))
244244
return false;
245245

246-
auto MaxCommonDivisor = [](int n) {
247-
if (n % 4 == 0)
248-
return 4;
249-
if (n % 2 == 0)
250-
return 2;
251-
else
252-
return 1;
253-
};
254-
255246
Type *ScalarTy = Scalar->getType();
256247
uint64_t ScalarSize = ScalarTy->getPrimitiveSizeInBits();
257248
unsigned MinVectorSize = TTI.getMinVectorRegisterBitWidth();
@@ -295,7 +286,7 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
295286
uint64_t OldScalarSizeInBytes = ScalarSizeInBytes;
296287
// Assign the greatest common divisor between UnalignedBytes and Offset to
297288
// ScalarSizeInBytes
298-
ScalarSizeInBytes = MaxCommonDivisor(UnalignedBytes);
289+
ScalarSizeInBytes = std::gcd(ScalarSizeInBytes, UnalignedBytes);
299290
ScalarSize = ScalarSizeInBytes * 8;
300291
VectorRange = OldScalarSizeInBytes / ScalarSizeInBytes;
301292
MinVecNumElts = MinVectorSize / ScalarSize;

0 commit comments

Comments
 (0)