Skip to content

Commit 0e3f580

Browse files
committed
use std::gcd instead self code
1 parent 3de48b7 commit 0e3f580

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();
@@ -257,7 +248,7 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
257248
uint64_t OldScalarSizeInBytes = ScalarSizeInBytes;
258249
// Assign the greatest common divisor between UnalignedBytes and Offset to
259250
// ScalarSizeInBytes
260-
ScalarSizeInBytes = MaxCommonDivisor(UnalignedBytes);
251+
ScalarSizeInBytes = std::gcd(ScalarSizeInBytes, UnalignedBytes);
261252
ScalarSize = ScalarSizeInBytes * 8;
262253
VectorRange = OldScalarSizeInBytes / ScalarSizeInBytes;
263254
MinVecNumElts = MinVectorSize / ScalarSize;

0 commit comments

Comments
 (0)