Skip to content

Commit

Permalink
[InstCombine][NFC] Add tests with icmp splat vectors and B masks
Browse files Browse the repository at this point in the history
Add tests to verifying future support for splat vectors containing poison/undef in llvm::decomposeBitTestICmp.

Differential Revision: https://reviews.llvm.org/D143031
  • Loading branch information
jmciver authored and RKSimon committed Apr 11, 2023
1 parent c2dda66 commit 353720a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions llvm/test/Transforms/InstCombine/icmp-logical.ll
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,36 @@ define i1 @fold_mask_cmps_to_true_logical(i32 %x) {
ret i1 %t4
}

define <2 x i1> @nomask_splat_and_B_allones(<2 x i32> %A) {
; CHECK-LABEL: @nomask_splat_and_B_allones(
; CHECK-NEXT: [[TST1:%.*]] = icmp slt <2 x i32> [[A:%.*]], <i32 0, i32 poison>
; CHECK-NEXT: [[MASK2:%.*]] = and <2 x i32> [[A]], <i32 1879048192, i32 1879048192>
; CHECK-NEXT: [[TST2:%.*]] = icmp eq <2 x i32> [[MASK2]], <i32 1879048192, i32 1879048192>
; CHECK-NEXT: [[RES:%.*]] = and <2 x i1> [[TST1]], [[TST2]]
; CHECK-NEXT: ret <2 x i1> [[RES]]
;
%tst1 = icmp slt <2 x i32> %A, <i32 0, i32 poison>
%mask2 = and <2 x i32> %A, <i32 1879048192, i32 1879048192>
%tst2 = icmp eq <2 x i32> %mask2, <i32 1879048192, i32 1879048192>
%res = and <2 x i1> %tst1, %tst2
ret <2 x i1> %res
}

define <2 x i1> @nomask_splat_and_B_mixed(<2 x i32> %A) {
; CHECK-LABEL: @nomask_splat_and_B_mixed(
; CHECK-NEXT: [[TST1:%.*]] = icmp sgt <2 x i32> [[A:%.*]], <i32 -1, i32 poison>
; CHECK-NEXT: [[MASK2:%.*]] = and <2 x i32> [[A]], <i32 1879048192, i32 1879048192>
; CHECK-NEXT: [[TST2:%.*]] = icmp eq <2 x i32> [[MASK2]], <i32 1879048192, i32 1879048192>
; CHECK-NEXT: [[RES:%.*]] = and <2 x i1> [[TST1]], [[TST2]]
; CHECK-NEXT: ret <2 x i1> [[RES]]
;
%tst1 = icmp sgt <2 x i32> %A, <i32 -1, i32 poison>
%mask2 = and <2 x i32> %A, <i32 1879048192, i32 1879048192>
%tst2 = icmp eq <2 x i32> %mask2, <i32 1879048192, i32 1879048192>
%res = and <2 x i1> %tst1, %tst2
ret <2 x i1> %res
}

; PR32401 - https://bugs.llvm.org/show_bug.cgi?id=32401

define i1 @cmpeq_bitwise(i8 %a, i8 %b, i8 %c, i8 %d) {
Expand Down

0 comments on commit 353720a

Please sign in to comment.