[llvm] 9d6ab72 - [GlobalISel] Use std::lcm (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 27 09:53:40 PDT 2022
Author: Kazu Hirata
Date: 2022-08-27T09:53:16-07:00
New Revision: 9d6ab7230b4b07a113e13b0958efbd2fc2ce6a73
URL: https://github.com/llvm/llvm-project/commit/9d6ab7230b4b07a113e13b0958efbd2fc2ce6a73
DIFF: https://github.com/llvm/llvm-project/commit/9d6ab7230b4b07a113e13b0958efbd2fc2ce6a73.diff
LOG: [GlobalISel] Use std::lcm (NFC)
This patch replaces getLCMSize with std::lcm, a C++17 feature.
Note that all the arguments are of unsigned with no implicit type
conversion as they are passed to getLCMSize.
Added:
Modified:
llvm/lib/CodeGen/GlobalISel/Utils.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/Utils.cpp b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
index 677e13dc7629..16b0d4753d28 100644
--- a/llvm/lib/CodeGen/GlobalISel/Utils.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
@@ -33,6 +33,7 @@
#include "llvm/IR/Constants.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/Utils/SizeOpts.h"
+#include <numeric>
#define DEBUG_TYPE "globalisel-utils"
@@ -880,12 +881,6 @@ void llvm::getSelectionDAGFallbackAnalysisUsage(AnalysisUsage &AU) {
AU.addPreserved<StackProtector>();
}
-static unsigned getLCMSize(unsigned OrigSize, unsigned TargetSize) {
- unsigned Mul = OrigSize * TargetSize;
- unsigned GCDSize = greatestCommonDivisor(OrigSize, TargetSize);
- return Mul / GCDSize;
-}
-
LLT llvm::getLCMType(LLT OrigTy, LLT TargetTy) {
const unsigned OrigSize = OrigTy.getSizeInBits();
const unsigned TargetSize = TargetTy.getSizeInBits();
@@ -912,16 +907,16 @@ LLT llvm::getLCMType(LLT OrigTy, LLT TargetTy) {
return OrigTy;
}
- unsigned LCMSize = getLCMSize(OrigSize, TargetSize);
+ unsigned LCMSize = std::lcm(OrigSize, TargetSize);
return LLT::fixed_vector(LCMSize / OrigElt.getSizeInBits(), OrigElt);
}
if (TargetTy.isVector()) {
- unsigned LCMSize = getLCMSize(OrigSize, TargetSize);
+ unsigned LCMSize = std::lcm(OrigSize, TargetSize);
return LLT::fixed_vector(LCMSize / OrigSize, OrigTy);
}
- unsigned LCMSize = getLCMSize(OrigSize, TargetSize);
+ unsigned LCMSize = std::lcm(OrigSize, TargetSize);
// Preserve pointer types.
if (LCMSize == OrigSize)
More information about the llvm-commits
mailing list