This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] precommit tests for D140666
ClosedPublic

Authored by inclyc on Jan 19 2023, 1:23 AM.

Details

Diff Detail

Event Timeline

inclyc created this revision.Jan 19 2023, 1:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 19 2023, 1:23 AM
inclyc requested review of this revision.Jan 19 2023, 1:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 19 2023, 1:23 AM
inclyc edited the summary of this revision. (Show Details)Jan 19 2023, 1:29 AM
inclyc added reviewers: nikic, spatel, bcl5980.

I'm not sure if you should add negative tests for
(~B & C) == 0 && (~D & E) == 0,
But we may need some more negative tests. At least one more for

!ConstB->isSubsetOf(*ConstD) && !ConstD->isSubsetOf(*ConstB)

It's better you can try more different constants in the different tests.
And we need at least 1 vector test.

inclyc updated this revision to Diff 493815.Jan 31 2023, 8:50 PM

But we may need some more negative tests. At least one more for

Add:

define i1 @masked_not_subset_notoptimized(i32 %A) {
; CHECK-LABEL: @masked_not_subset_notoptimized(
; CHECK-NEXT:    [[MASK1:%.*]] = and i32 [[A:%.*]], 254
; CHECK-NEXT:    [[TST1:%.*]] = icmp ne i32 [[MASK1]], 252
; CHECK-NEXT:    [[MASK2:%.*]] = and i32 [[A]], 253
; CHECK-NEXT:    [[TST2:%.*]] = icmp ne i32 [[MASK2]], 252
; CHECK-NEXT:    [[RES:%.*]] = and i1 [[TST1]], [[TST2]]
; CHECK-NEXT:    ret i1 [[RES]]
;
  %mask1 = and i32 %A, 254 ; 0xfe
  %tst1 = icmp ne i32 %mask1, 252 ; 0xfc
  %mask2 = and i32 %A, 253 ; 0xfd
  %tst2 = icmp ne i32 %mask2, 252 ; 0xfc
  %res = and i1 %tst1, %tst2
  ret i1 %res
}

And we need at least 1 vector test.

I may not understand what you mean :(. We are doing an optimization on scalar right now?

But we may need some more negative tests. At least one more for

Add:

define i1 @masked_not_subset_notoptimized(i32 %A) {
; CHECK-LABEL: @masked_not_subset_notoptimized(
; CHECK-NEXT:    [[MASK1:%.*]] = and i32 [[A:%.*]], 254
; CHECK-NEXT:    [[TST1:%.*]] = icmp ne i32 [[MASK1]], 252
; CHECK-NEXT:    [[MASK2:%.*]] = and i32 [[A]], 253
; CHECK-NEXT:    [[TST2:%.*]] = icmp ne i32 [[MASK2]], 252
; CHECK-NEXT:    [[RES:%.*]] = and i1 [[TST1]], [[TST2]]
; CHECK-NEXT:    ret i1 [[RES]]
;
  %mask1 = and i32 %A, 254 ; 0xfe
  %tst1 = icmp ne i32 %mask1, 252 ; 0xfc
  %mask2 = and i32 %A, 253 ; 0xfd
  %tst2 = icmp ne i32 %mask2, 252 ; 0xfc
  %res = and i1 %tst1, %tst2
  ret i1 %res
}

And we need at least 1 vector test.

I may not understand what you mean :(. We are doing an optimization on scalar right now?

Take a look @masked_and_notallzeroes_splat in this file.
And it's better to add a test that replace one of the value to poison for splat constant also.
Another example in recent patch D142783:
@dec_zext_add_nonzero_vec , @dec_zext_add_nonzero_vec_poison1

inclyc updated this revision to Diff 494134.Feb 1 2023, 6:12 PM
  • add splat vector tests
bcl5980 accepted this revision.Feb 2 2023, 2:23 AM

LGTM

This revision is now accepted and ready to land.Feb 2 2023, 2:23 AM
This revision was automatically updated to reflect the committed changes.