mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-21 20:12:56 +02:00
d4059ff8b7
In my previous change to CVP (251606), I made CVP much more aggressive about trying to constant fold comparisons. This patch is a reversal in direction. Rather than being agressive about every compare, we restore the non-block local restriction for most, and then try hard for compares feeding returns. The motivation for this is two fold: * The more I thought about it, the less comfortable I got with the possible compile time impact of the other approach. There have been no reported issues, but after talking to a couple of folks, I've come to the conclusion the time probably isn't justified. * It turns out we need to know the context to leverage the full power of LVI. In particular, asking about something at the end of it's block (the use of a compare in a return) will frequently get more precise results than something in the middle of a block. This is an implementation detail, but it's also hard to get around since mid-block queries have to reason about possible throwing instructions and don't get to use most of LVI's block focused infrastructure. This will become particular important when combined with http://reviews.llvm.org/D14263. Differential Revision: http://reviews.llvm.org/D14271 llvm-svn: 252032
76 lines
1.4 KiB
LLVM
76 lines
1.4 KiB
LLVM
; RUN: opt < %s -correlated-propagation -S | FileCheck %s
|
|
|
|
; CHECK-LABEL: @simple(
|
|
define i8 @simple(i1) {
|
|
entry:
|
|
%s = select i1 %0, i8 0, i8 1
|
|
br i1 %0, label %then, label %else
|
|
|
|
then:
|
|
; CHECK: ret i8 0
|
|
%a = phi i8 [ %s, %entry ]
|
|
ret i8 %a
|
|
|
|
else:
|
|
; CHECK: ret i8 1
|
|
%b = phi i8 [ %s, %entry ]
|
|
ret i8 %b
|
|
}
|
|
|
|
; CHECK-LABEL: @loop(
|
|
define void @loop(i32) {
|
|
entry:
|
|
br label %loop
|
|
|
|
loop:
|
|
%idx = phi i32 [ %0, %entry ], [ %sel, %loop ]
|
|
; CHECK: %idx = phi i32 [ %0, %entry ], [ %2, %loop ]
|
|
%1 = icmp eq i32 %idx, 0
|
|
%2 = add i32 %idx, -1
|
|
%sel = select i1 %1, i32 0, i32 %2
|
|
br i1 %1, label %out, label %loop
|
|
|
|
out:
|
|
ret void
|
|
}
|
|
|
|
; CHECK-LABEL: @not_correlated(
|
|
define i8 @not_correlated(i1, i1) {
|
|
entry:
|
|
%s = select i1 %0, i8 0, i8 1
|
|
br i1 %1, label %then, label %else
|
|
|
|
then:
|
|
; CHECK: ret i8 %s
|
|
%a = phi i8 [ %s, %entry ]
|
|
ret i8 %a
|
|
|
|
else:
|
|
; CHECK: ret i8 %s
|
|
%b = phi i8 [ %s, %entry ]
|
|
ret i8 %b
|
|
}
|
|
|
|
@c = global i32 0, align 4
|
|
@b = global i32 0, align 4
|
|
|
|
; CHECK-LABEL: @PR23752(
|
|
define i32 @PR23752() {
|
|
entry:
|
|
br label %for.body
|
|
|
|
for.body:
|
|
%phi = phi i32 [ 0, %entry ], [ %sel, %for.body ]
|
|
%sel = select i1 icmp sgt (i32* @b, i32* @c), i32 %phi, i32 1
|
|
%cmp = icmp ne i32 %sel, 1
|
|
br i1 %cmp, label %for.body, label %if.end
|
|
|
|
; CHECK: %[[sel:.*]] = select i1 icmp sgt (i32* @b, i32* @c), i32 0, i32 1
|
|
; CHECK-NEXT: %[[cmp:.*]] = icmp ne i32 %[[sel]], 1
|
|
; CHECK-NEXT: br i1 %[[cmp]]
|
|
|
|
if.end:
|
|
ret i32 %sel
|
|
; CHECK: ret i32 1
|
|
}
|