[llvm] r340245 - [AST] Mark invariant.starts as being readonly
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 20 17:55:35 PDT 2018
Author: reames
Date: Mon Aug 20 17:55:35 2018
New Revision: 340245
URL: http://llvm.org/viewvc/llvm-project?rev=340245&view=rev
Log:
[AST] Mark invariant.starts as being readonly
These intrinsics are modelled as writing for control flow purposes, but they don't actually write to any location. Marking these - as we did for guards - allows LICM to hoist loads out of loops containing invariant.starts.
Differential Revision: https://reviews.llvm.org/D50861
Modified:
llvm/trunk/lib/Analysis/AliasSetTracker.cpp
llvm/trunk/test/Transforms/LICM/invariant.start.ll
Modified: llvm/trunk/lib/Analysis/AliasSetTracker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasSetTracker.cpp?rev=340245&r1=340244&r2=340245&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/AliasSetTracker.cpp (original)
+++ llvm/trunk/lib/Analysis/AliasSetTracker.cpp Mon Aug 20 17:55:35 2018
@@ -174,7 +174,8 @@ void AliasSet::addUnknownInst(Instructio
// but don't actually modify any specific memory location.
using namespace PatternMatch;
bool MayWriteMemory = I->mayWriteToMemory() &&
- !match(I, m_Intrinsic<Intrinsic::experimental_guard>());
+ !match(I, m_Intrinsic<Intrinsic::experimental_guard>()) &&
+ !(I->use_empty() && match(I, m_Intrinsic<Intrinsic::invariant_start>()));
if (!MayWriteMemory) {
Alias = SetMayAlias;
Access |= RefAccess;
Modified: llvm/trunk/test/Transforms/LICM/invariant.start.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LICM/invariant.start.ll?rev=340245&r1=340244&r2=340245&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LICM/invariant.start.ll (original)
+++ llvm/trunk/test/Transforms/LICM/invariant.start.ll Mon Aug 20 17:55:35 2018
@@ -7,9 +7,9 @@
define void @test1(i1 %cond, i32* %ptr) {
; CHECK-LABEL: @test1(
; CHECK-LABEL: entry:
+; CHECK: %val = load i32, i32* %ptr
; CHECK-LABEL: loop:
; CHECK: call {}* @llvm.invariant.start.p0i32(i64 4, i32* %ptr)
-; CHECK: %val = load i32, i32* %ptr
; ALIAS-N2-LABEL: @test1(
; ALIAS-N2-LABEL: entry:
@@ -28,14 +28,14 @@ loop:
br label %loop
}
-;; TODO: By default, despite the loop varying invariant.start, we should be
+;; despite the loop varying invariant.start, we should be
;; able to hoist the load
define void @test2(i1 %cond, i32* %ptr) {
; CHECK-LABEL: @test2(
; CHECK-LABEL: entry:
+; CHECK: %val = load i32, i32* %ptr
; CHECK-LABEL: loop:
; CHECK: call {}* @llvm.invariant.start.p0i32(i64 4, i32* %piv)
-; CHECK: %val = load i32, i32* %ptr
; ALIAS-N2-LABEL: @test2(
; ALIAS-N2-LABEL: entry:
@@ -54,13 +54,12 @@ loop:
br label %loop
}
-; By default, should be able to hoist since store doesn't alias
define void @test3(i1 %cond, i32* %ptr) {
; CHECK-LABEL: @test3(
; CHECK-LABEL: entry:
+; CHECK: %val = load i32, i32* %ptr
; CHECK-LABEL: loop:
; CHECK: call {}* @llvm.invariant.start.p0i32(i64 4, i32* %ptr)
-; CHECK: %val = load i32, i32* %ptr
; ALIAS-N2-LABEL: @test3(
; ALIAS-N2-LABEL: entry:
More information about the llvm-commits
mailing list