llvm-6502/test/Transforms/CorrelatedValuePropagation/select.ll
Bjorn Steinbrink 1b8b7d61ee CVP: Improve handling of Selects used as incoming PHI values
Summary:
If the branch that leads to the PHI node and the Select instruction
depend on correlated conditions, we might be able to directly use the
corresponding value from the Select instruction as the incoming value
for the PHI node, allowing later removal of the select instruction.

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D9051

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237201 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-12 22:31:47 +00:00

54 lines
924 B
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
}