[PATCH] D68494: [PATCH 11/38] [noalias] D9377: llvm.noalias - don't block EarlyCSE
Jeroen Dobbelaere via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 4 14:40:15 PDT 2019
jeroen.dobbelaere created this revision.
jeroen.dobbelaere added reviewers: hfinkel, jdoerfert.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
This is part of the series started by D68484 <https://reviews.llvm.org/D68484>.
Rebase of D9377 <https://reviews.llvm.org/D9377>
https://reviews.llvm.org/D68494
Files:
llvm/lib/Transforms/Scalar/EarlyCSE.cpp
llvm/test/Transforms/EarlyCSE/basic.ll
Index: llvm/test/Transforms/EarlyCSE/basic.ll
===================================================================
--- llvm/test/Transforms/EarlyCSE/basic.ll
+++ llvm/test/Transforms/EarlyCSE/basic.ll
@@ -54,6 +54,16 @@
; CHECK: ret i32 0
}
+; CHECK-LABEL: @test2b(
+define i32 @test2b(i32 *%P, i1 %b) {
+ %V1 = load i32, i32* %P
+ call i8* @llvm.noalias.p0i8(i8* undef, metadata !1)
+ %V2 = load i32, i32* %P
+ %Diff = sub i32 %V1, %V2
+ ret i32 %Diff
+ ; CHECK: ret i32 0
+}
+
;; Cross block load value numbering.
; CHECK-LABEL: @test3(
define i32 @test3(i32 *%P, i1 %Cond) {
@@ -134,6 +144,15 @@
; CHECK: ret i32 42
}
+; CHECK-LABEL: @test6b(
+define i32 @test6b(i32 *%P, i1 %b) {
+ store i32 42, i32* %P
+ call i8* @llvm.noalias.p0i8(i8* undef, metadata !1)
+ %V1 = load i32, i32* %P
+ ret i32 %V1
+ ; CHECK: ret i32 42
+}
+
;; Trivial dead store elimination.
; CHECK-LABEL: @test7(
define void @test7(i32 *%P) {
@@ -291,3 +310,8 @@
store i32 2, i32* @c, align 4
ret void
}
+
+declare i8* @llvm.noalias.p0i8(i8*, metadata) nounwind
+
+!0 = !{!0, !"some domain"}
+!1 = !{!1, !0, !"some scope"}
Index: llvm/lib/Transforms/Scalar/EarlyCSE.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/EarlyCSE.cpp
+++ llvm/lib/Transforms/Scalar/EarlyCSE.cpp
@@ -932,8 +932,10 @@
}
// Skip sideeffect intrinsics, for the same reason as assume intrinsics.
- if (match(Inst, m_Intrinsic<Intrinsic::sideeffect>())) {
- LLVM_DEBUG(dbgs() << "EarlyCSE skipping sideeffect: " << *Inst << '\n');
+ // Likewise, noalias intrinsics don't actually write.
+ if (match(Inst, m_CombineOr(m_Intrinsic<Intrinsic::sideeffect>(),
+ m_Intrinsic<Intrinsic::assume>()))) {
+ LLVM_DEBUG(dbgs() << "EarlyCSE skipping intrinsic: " << *Inst << '\n');
continue;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68494.223294.patch
Type: text/x-patch
Size: 1891 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191004/10df74ed/attachment.bin>
More information about the llvm-commits
mailing list