mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-26 13:36:28 +00:00
f7df28c1f5
branch "br i1 %x, label %if_true, label %if_false" then it replaces "%x" with "true" in places only reachable via the %if_true arm, and with "false" in places only reachable via the %if_false arm. Except that actually it doesn't: if value numbering shows that %y is equal to %x then, yes, %y will be turned into true/false in this way, but any occurrences of %x itself are not transformed. Fix this. What's more, it's often the case that %x is an equality comparison such as "%x = icmp eq %A, 0", in which case every occurrence of %A that is only reachable via the %if_true arm can be replaced with 0. Implement this and a few other variations on this theme. This reduces the number of lines of LLVM IR in "GCC as one big file" by 0.2%. It has a bigger impact on Ada code, typically reducing the number of lines of bitcode by around 0.4% by removing repeated compiler generated checks. Passes the LLVM nightly testsuite and the Ada ACATS testsuite. llvm-svn: 141177
32 lines
716 B
LLVM
32 lines
716 B
LLVM
; RUN: opt -basicaa -gvn -S < %s | FileCheck %s
|
|
|
|
target datalayout = "e-p:64:64:64"
|
|
|
|
; CHECK: @foo
|
|
; CHECK: entry.end_crit_edge:
|
|
; CHECK: %n.pre = load i32* %q.phi.trans.insert
|
|
; CHECK: then:
|
|
; CHECK: store i32 %z
|
|
; CHECK: end:
|
|
; CHECK: %n = phi i32 [ %n.pre, %entry.end_crit_edge ], [ %z, %then ]
|
|
; CHECK: ret i32 %n
|
|
|
|
@G = external global [100 x i32]
|
|
define i32 @foo(i32 %x, i32 %z) {
|
|
entry:
|
|
%tobool = icmp eq i32 %z, 0
|
|
br i1 %tobool, label %end, label %then
|
|
|
|
then:
|
|
%i = sext i32 %x to i64
|
|
%p = getelementptr [100 x i32]* @G, i64 0, i64 %i
|
|
store i32 %z, i32* %p
|
|
br label %end
|
|
|
|
end:
|
|
%j = sext i32 %x to i64
|
|
%q = getelementptr [100 x i32]* @G, i64 0, i64 %j
|
|
%n = load i32* %q
|
|
ret i32 %n
|
|
}
|