[llvm] [GVN] No need to swap if both LHS and RHS are arguments (PR #95566)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 14 09:52:50 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: AdityaK (hiraditya)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/95566.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Scalar/GVN.cpp (+1-1)
``````````diff
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index b5be8ac249417..fa7be681e3f0a 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2472,7 +2472,7 @@ bool GVNPass::propagateEquality(Value *LHS, Value *RHS,
continue;
// Prefer a constant on the right-hand side, or an Argument if no constants.
- if (isa<Constant>(LHS) || (isa<Argument>(LHS) && !isa<Constant>(RHS)))
+ if (isa<Constant>(LHS) || (isa<Argument>(LHS) && !isa<Argument>(RHS) && !isa<Constant>(RHS)))
std::swap(LHS, RHS);
assert((isa<Argument>(LHS) || isa<Instruction>(LHS)) && "Unexpected value!");
const DataLayout &DL =
``````````
</details>
https://github.com/llvm/llvm-project/pull/95566
More information about the llvm-commits
mailing list