2013-09-17 05:24:30 +08:00
|
|
|
; RUN: opt -basicaa -sroa -loop-rotate -licm -S < %s | FileCheck %s
|
2017-01-11 12:39:35 +08:00
|
|
|
; RUN: opt -basicaa -sroa -loop-rotate %s | opt -aa-pipeline=basic-aa -passes='require<aa>,require<targetir>,require<scalar-evolution>,require<opt-remark-emit>,loop(licm)' -S | FileCheck %s
|
2013-09-17 05:24:30 +08:00
|
|
|
; The objects *p and *q are aliased to each other, but even though *q is
|
|
|
|
; volatile, *p can be considered invariant in the loop. Check if it is moved
|
|
|
|
; out of the loop.
|
2015-02-28 05:17:42 +08:00
|
|
|
; CHECK: load i32, i32* %p
|
2013-09-17 05:24:30 +08:00
|
|
|
; CHECK: for.body:
|
2015-02-28 05:17:42 +08:00
|
|
|
; CHECK: load volatile i32, i32* %q
|
2013-09-17 05:24:30 +08:00
|
|
|
|
|
|
|
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
|
|
|
|
|
|
|
|
; Function Attrs: nounwind uwtable
|
[LICM] Make isGuaranteedToExecute more accurate.
Summary:
Make isGuaranteedToExecute use the
isGuaranteedToTransferExecutionToSuccessor helper, and make that helper
a bit more accurate.
There's a potential performance impact here from assuming that arbitrary
calls might not return. This probably has little impact on loads and
stores to a pointer because most things alias analysis can reason about
are dereferenceable anyway. The other impacts, like less aggressive
hoisting of sdiv by a variable and less aggressive hoisting around
volatile memory operations, are unlikely to matter for real code.
This also impacts SCEV, which uses the same helper. It's a minor
improvement there because we can tell that, for example, memcpy always
returns normally. Strictly speaking, it's also introducing
a bug, but it's not any worse than everywhere else we assume readonly
functions terminate.
Fixes http://llvm.org/PR27857.
Reviewers: hfinkel, reames, chandlerc, sanjoy
Subscribers: broune, llvm-commits
Differential Revision: http://reviews.llvm.org/D21167
llvm-svn: 272489
2016-06-12 05:48:25 +08:00
|
|
|
define i32 @foo(i32* dereferenceable(4) nonnull %p, i32* %q, i32 %n) #0 {
|
2013-09-17 05:24:30 +08:00
|
|
|
entry:
|
|
|
|
%p.addr = alloca i32*, align 8
|
|
|
|
%q.addr = alloca i32*, align 8
|
|
|
|
%n.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
%s = alloca i32, align 4
|
|
|
|
store i32* %p, i32** %p.addr, align 8
|
|
|
|
store i32* %q, i32** %q.addr, align 8
|
|
|
|
store i32 %n, i32* %n.addr, align 4
|
|
|
|
store i32 0, i32* %s, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
|
|
|
%1 = load i32, i32* %n.addr, align 4
|
2013-09-17 05:24:30 +08:00
|
|
|
%cmp = icmp slt i32 %0, %1
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32*, i32** %p.addr, align 8
|
|
|
|
%3 = load i32, i32* %2, align 4
|
|
|
|
%4 = load i32*, i32** %q.addr, align 8
|
|
|
|
%5 = load volatile i32, i32* %4, align 4
|
2013-09-17 05:24:30 +08:00
|
|
|
%add = add nsw i32 %3, %5
|
2015-02-28 05:17:42 +08:00
|
|
|
%6 = load i32, i32* %s, align 4
|
2013-09-17 05:24:30 +08:00
|
|
|
%add1 = add nsw i32 %6, %add
|
|
|
|
store i32 %add1, i32* %s, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %i, align 4
|
2013-09-17 05:24:30 +08:00
|
|
|
%inc = add nsw i32 %7, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%8 = load i32, i32* %s, align 4
|
2013-09-17 05:24:30 +08:00
|
|
|
ret i32 %8
|
|
|
|
}
|
|
|
|
|
|
|
|
attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
|