diff options
author | Noah Goldstein <goldstein.w.n@gmail.com> | 2024-09-17 00:06:28 -0500 |
---|---|---|
committer | Noah Goldstein <goldstein.w.n@gmail.com> | 2024-09-17 12:04:34 -0500 |
commit | 419c53477eae62c716ca8f4e18109342f0398d95 (patch) | |
tree | 99108332ab66aecfaa7db580f02576ddaac3c073 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | ae8d0200b052234c38a89b93dcac447e95f99554 (diff) | |
download | llvm-419c53477eae62c716ca8f4e18109342f0398d95.zip llvm-419c53477eae62c716ca8f4e18109342f0398d95.tar.gz llvm-419c53477eae62c716ca8f4e18109342f0398d95.tar.bz2 |
[SimplifyCFG] Mark div/rem as not-cheap to sink if we are replacing const denominator
Close #109007
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 1a4820e..c63618d 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1954,6 +1954,9 @@ static bool isLifeTimeMarker(const Instruction *I) { // into variables. static bool replacingOperandWithVariableIsCheap(const Instruction *I, int OpIdx) { + // Divide/Remainder by constant is typically much cheaper than by variable. + if (I->isIntDivRem()) + return OpIdx != 1; return !isa<IntrinsicInst>(I); } |