1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00
llvm-mirror/test/Transforms/NewGVN/cond_br.ll
Davide Italiano bd0298b1e1 [GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...

The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.

Differential Revision:  https://reviews.llvm.org/D26224

llvm-svn: 290346
2016-12-22 16:03:48 +00:00

56 lines
1.6 KiB
LLVM

; RUN: opt -basicaa -newgvn -S < %s | FileCheck %s
@y = external global i32
@z = external global i32
; Function Attrs: nounwind ssp uwtable
define void @foo(i32 %x) {
; CHECK: @foo(i32 %x)
; CHECK: %.pre = load i32, i32* @y
; CHECK: call void @bar(i32 %.pre)
%t = sub i32 %x, %x
%.pre = load i32, i32* @y, align 4
%cmp = icmp sgt i32 %t, 2
br i1 %cmp, label %if.then, label %entry.if.end_crit_edge
entry.if.end_crit_edge: ; preds = %entry
br label %if.end
if.then: ; preds = %entry
%add = add nsw i32 %x, 3
store i32 %add, i32* @y, align 4
br label %if.end
if.end: ; preds = %entry.if.end_crit_edge, %if.then
%1 = phi i32 [ %.pre, %entry.if.end_crit_edge ], [ %add, %if.then ]
tail call void @bar(i32 %1)
ret void
}
define void @foo2(i32 %x) {
; CHECK: @foo2(i32 %x)
; CHECK: %.pre = load i32, i32* @y
; CHECK: tail call void @bar(i32 %.pre)
entry:
%t = sub i32 %x, %x
%.pre = load i32, i32* @y, align 4
%cmp = icmp sgt i32 %t, 2
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
%add = add nsw i32 %x, 3
store i32 %add, i32* @y, align 4
br label %if.end
if.else: ; preds = %entry
store i32 1, i32* @z, align 4
br label %if.end
if.end: ; preds = %if.else, %if.then
%0 = phi i32 [ %.pre, %if.else ], [ %add, %if.then ]
tail call void @bar(i32 %0)
ret void
}
declare void @bar(i32)