forked from OSchip/llvm-project
[Test] Add test showing missing opportunity of folding ICmp(Phi(Consts...))
This commit is contained in:
parent
9d739a9157
commit
18134511d9
|
@ -0,0 +1,135 @@
|
|||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -instcombine -S | FileCheck %s
|
||||
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
|
||||
|
||||
; TODO: Replace with boolean Phi.
|
||||
|
||||
define i1 @test_eq(i1 %cond) {
|
||||
; CHECK-LABEL: @test_eq(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
|
||||
; CHECK: if.true:
|
||||
; CHECK-NEXT: br label [[MERGE:%.*]]
|
||||
; CHECK: if.false:
|
||||
; CHECK-NEXT: br label [[MERGE]]
|
||||
; CHECK: merge:
|
||||
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ 123, [[IF_TRUE]] ], [ 456, [[IF_FALSE]] ]
|
||||
; CHECK-NEXT: br label [[EXIT:%.*]]
|
||||
; CHECK: exit:
|
||||
; CHECK-NEXT: [[COMPARE:%.*]] = icmp eq i32 [[PHI]], 456
|
||||
; CHECK-NEXT: ret i1 [[COMPARE]]
|
||||
;
|
||||
entry:
|
||||
br i1 %cond, label %if.true, label %if.false
|
||||
|
||||
if.true:
|
||||
br label %merge
|
||||
|
||||
if.false:
|
||||
br label %merge
|
||||
|
||||
merge:
|
||||
%phi = phi i32 [123, %if.true], [456, %if.false]
|
||||
br label %exit
|
||||
|
||||
exit:
|
||||
%compare = icmp eq i32 %phi, 456
|
||||
ret i1 %compare
|
||||
}
|
||||
|
||||
define i1 @test_slt(i1 %cond) {
|
||||
; CHECK-LABEL: @test_slt(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
|
||||
; CHECK: if.true:
|
||||
; CHECK-NEXT: br label [[MERGE:%.*]]
|
||||
; CHECK: if.false:
|
||||
; CHECK-NEXT: br label [[MERGE]]
|
||||
; CHECK: merge:
|
||||
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ 123, [[IF_TRUE]] ], [ 456, [[IF_FALSE]] ]
|
||||
; CHECK-NEXT: br label [[EXIT:%.*]]
|
||||
; CHECK: exit:
|
||||
; CHECK-NEXT: [[COMPARE:%.*]] = icmp ult i32 [[PHI]], 456
|
||||
; CHECK-NEXT: ret i1 [[COMPARE]]
|
||||
;
|
||||
entry:
|
||||
br i1 %cond, label %if.true, label %if.false
|
||||
|
||||
if.true:
|
||||
br label %merge
|
||||
|
||||
if.false:
|
||||
br label %merge
|
||||
|
||||
merge:
|
||||
%phi = phi i32 [123, %if.true], [456, %if.false]
|
||||
br label %exit
|
||||
|
||||
exit:
|
||||
%compare = icmp slt i32 %phi, 456
|
||||
ret i1 %compare
|
||||
}
|
||||
|
||||
define i1 @test_sle(i1 %cond) {
|
||||
; CHECK-LABEL: @test_sle(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
|
||||
; CHECK: if.true:
|
||||
; CHECK-NEXT: br label [[MERGE:%.*]]
|
||||
; CHECK: if.false:
|
||||
; CHECK-NEXT: br label [[MERGE]]
|
||||
; CHECK: merge:
|
||||
; CHECK-NEXT: br label [[EXIT:%.*]]
|
||||
; CHECK: exit:
|
||||
; CHECK-NEXT: ret i1 true
|
||||
;
|
||||
entry:
|
||||
br i1 %cond, label %if.true, label %if.false
|
||||
|
||||
if.true:
|
||||
br label %merge
|
||||
|
||||
if.false:
|
||||
br label %merge
|
||||
|
||||
merge:
|
||||
%phi = phi i32 [123, %if.true], [456, %if.false]
|
||||
br label %exit
|
||||
|
||||
exit:
|
||||
%compare = icmp sle i32 %phi, 456
|
||||
ret i1 %compare
|
||||
}
|
||||
|
||||
define i1 @test_ne(i1 %cond) {
|
||||
; CHECK-LABEL: @test_ne(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
|
||||
; CHECK: if.true:
|
||||
; CHECK-NEXT: br label [[MERGE:%.*]]
|
||||
; CHECK: if.false:
|
||||
; CHECK-NEXT: br label [[MERGE]]
|
||||
; CHECK: merge:
|
||||
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ 123, [[IF_TRUE]] ], [ 456, [[IF_FALSE]] ]
|
||||
; CHECK-NEXT: br label [[EXIT:%.*]]
|
||||
; CHECK: exit:
|
||||
; CHECK-NEXT: [[COMPARE:%.*]] = icmp ne i32 [[PHI]], 456
|
||||
; CHECK-NEXT: ret i1 [[COMPARE]]
|
||||
;
|
||||
entry:
|
||||
br i1 %cond, label %if.true, label %if.false
|
||||
|
||||
if.true:
|
||||
br label %merge
|
||||
|
||||
if.false:
|
||||
br label %merge
|
||||
|
||||
merge:
|
||||
%phi = phi i32 [123, %if.true], [456, %if.false]
|
||||
br label %exit
|
||||
|
||||
exit:
|
||||
%compare = icmp ne i32 %phi, 456
|
||||
ret i1 %compare
|
||||
}
|
Loading…
Reference in New Issue