diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2022-05-08 00:54:53 +0000 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2022-05-18 23:20:08 +0900 |
commit | 6ca7eb2c6d7da2264f410f270633bf698ab5d87d (patch) | |
tree | f40da2ef381810cab471073aed7795d92ddbbb50 /llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | |
parent | 47258ffc5c7aa9ae2017bdde58a88e0f928d8f07 (diff) | |
download | llvm-6ca7eb2c6d7da2264f410f270633bf698ab5d87d.zip llvm-6ca7eb2c6d7da2264f410f270633bf698ab5d87d.tar.gz llvm-6ca7eb2c6d7da2264f410f270633bf698ab5d87d.tar.bz2 |
[SCEV] Part 1, Serialize function calls in function arguments.
Evaluation odering in function call arguments is implementation-dependent.
In fact, gcc evaluates bottom-top and clang does top-bottom.
Fixes #55283 partially.
Part of https://reviews.llvm.org/D125627
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp index 71cce3e..6617fde 100644 --- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp @@ -159,11 +159,12 @@ Value *SimplifyIndvar::foldIVUser(Instruction *UseInst, Instruction *IVOperand) D = ConstantInt::get(UseInst->getContext(), APInt::getOneBitSet(BitWidth, D->getZExtValue())); } - FoldedExpr = SE->getUDivExpr(SE->getSCEV(IVSrc), SE->getSCEV(D)); + const auto *LHS = SE->getSCEV(IVSrc); + const auto *RHS = SE->getSCEV(D); + FoldedExpr = SE->getUDivExpr(LHS, RHS); // We might have 'exact' flag set at this point which will no longer be // correct after we make the replacement. - if (UseInst->isExact() && - SE->getSCEV(IVSrc) != SE->getMulExpr(FoldedExpr, SE->getSCEV(D))) + if (UseInst->isExact() && LHS != SE->getMulExpr(FoldedExpr, RHS)) MustDropExactFlag = true; } // We have something that might fold it's operand. Compare SCEVs. |