[NFC][InstCombine] Add a test for D50465 that used to assert

This is valid to fold, too.
https://rise4fun.com/Alive/0lz

llvm-svn: 339619
This commit is contained in:
Roman Lebedev 2018-08-13 21:49:33 +00:00
parent 15bff18c6f
commit 93f7e7f03e
1 changed files with 19 additions and 0 deletions

View File

@ -101,6 +101,25 @@ define i1 @positive_with_aggressive_icmp(i32 %arg) {
; I'm sure there is a bunch more patterns possible :/
; This used to trigger an assert, because the icmp's are not direct
; operands of the and.
define i1 @positive_with_extra_and(i32 %arg, i1 %z) {
; CHECK-LABEL: @positive_with_extra_and(
; CHECK-NEXT: [[T1:%.*]] = icmp sgt i32 [[ARG:%.*]], -1
; CHECK-NEXT: [[T2:%.*]] = add i32 [[ARG]], 128
; CHECK-NEXT: [[T3:%.*]] = icmp ult i32 [[T2]], 256
; CHECK-NEXT: [[T4:%.*]] = and i1 [[T1]], [[Z:%.*]]
; CHECK-NEXT: [[T5:%.*]] = and i1 [[T3]], [[T4]]
; CHECK-NEXT: ret i1 [[T5]]
;
%t1 = icmp sgt i32 %arg, -1
%t2 = add i32 %arg, 128
%t3 = icmp ult i32 %t2, 256
%t4 = and i1 %t1, %z
%t5 = and i1 %t3, %t4
ret i1 %t5
}
; ============================================================================ ;
; Vector tests
; ============================================================================ ;