[llvm] [GVN] Handle empty attrs in Expression == (PR #115761)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 11 11:48:35 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: None (macurtis-amd)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/115761.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/Scalar/GVN.cpp (+1-1)
- (added) llvm/test/Transforms/GVN/intersect-empty-attr.ll (+19)
``````````diff
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index e27f5a08c85a97..a3df7a0a39e6b2 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -156,7 +156,7 @@ struct llvm::GVNPass::Expression {
return false;
if (varargs != other.varargs)
return false;
- if (!attrs.isEmpty() && !other.attrs.isEmpty() &&
+ if ((!attrs.isEmpty() || !other.attrs.isEmpty()) &&
!attrs.intersectWith(type->getContext(), other.attrs).has_value())
return false;
return true;
diff --git a/llvm/test/Transforms/GVN/intersect-empty-attr.ll b/llvm/test/Transforms/GVN/intersect-empty-attr.ll
new file mode 100644
index 00000000000000..013b01c700ce4e
--- /dev/null
+++ b/llvm/test/Transforms/GVN/intersect-empty-attr.ll
@@ -0,0 +1,19 @@
+; RUN: opt -S -passes=gvn < %s | FileCheck %s
+
+declare i32 @bar() #0
+
+define i32 @foo() {
+entry:
+ %0 = tail call i32 @bar() #1
+ %1 = tail call i32 @bar()
+ ret i32 1
+}
+
+; CHECK-LABEL: define i32 @foo(
+; CHECK: %0 = tail call i32 @bar() #1
+; CHECK-NEXT: %1 = tail call i32 @bar()
+; CHECK-NEXT: ret i32 1
+; CHECK-NEXT: }
+
+attributes #0 = { memory(none) }
+attributes #1 = { "llvm.assume"="ompx_no_call_asm" }
``````````
</details>
https://github.com/llvm/llvm-project/pull/115761
More information about the llvm-commits
mailing list