[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:18 PDT 2024
https://github.com/hiraditya created https://github.com/llvm/llvm-project/pull/95566
None
>From 1689466ba6034d9e980f3e47c89539f21e50f2b2 Mon Sep 17 00:00:00 2001
From: AdityaK <hiraditya at msn.com>
Date: Fri, 14 Jun 2024 09:49:22 -0700
Subject: [PATCH] No need to swap if both LHS and RHS are arguments
---
llvm/lib/Transforms/Scalar/GVN.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 =
More information about the llvm-commits
mailing list