[llvm] e298dfb - [SCCP] Avoid ConstantExpr::get() call
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 13 07:21:20 PDT 2022
Author: Nikita Popov
Date: 2022-07-13T16:20:34+02:00
New Revision: e298dfbc1b89fb7e0051f978bf859d6c37fd9203
URL: https://github.com/llvm/llvm-project/commit/e298dfbc1b89fb7e0051f978bf859d6c37fd9203
DIFF: https://github.com/llvm/llvm-project/commit/e298dfbc1b89fb7e0051f978bf859d6c37fd9203.diff
LOG: [SCCP] Avoid ConstantExpr::get() call
Use ConstantFoldUnaryOpOperand() API instead. This is in
preparation for removing fneg constant expressions.
Added:
Modified:
llvm/lib/Transforms/Utils/SCCPSolver.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/SCCPSolver.cpp b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
index eee91e70292e3..241e054cbf30d 100644
--- a/llvm/lib/Transforms/Utils/SCCPSolver.cpp
+++ b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
@@ -960,12 +960,13 @@ void SCCPInstVisitor::visitUnaryOperator(Instruction &I) {
return (void)markOverdefined(&I);
if (isConstant(V0State)) {
- Constant *C = ConstantExpr::get(I.getOpcode(), getConstant(V0State));
-
- // op Y -> undef.
- if (isa<UndefValue>(C))
- return;
- return (void)markConstant(IV, &I, C);
+ if (Constant *C = ConstantFoldUnaryOpOperand(I.getOpcode(),
+ getConstant(V0State, DL))) {
+ // op Y -> undef.
+ if (isa<UndefValue>(C))
+ return;
+ return (void)markConstant(IV, &I, C);
+ }
}
// If something is undef, wait for it to resolve.
More information about the llvm-commits
mailing list