[PATCH] D122152: [InstCombine] Fold two select patterns into and-or

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 27 07:03:46 PDT 2022


spatel added a comment.

I think the tests are still insufficient to provide coverage for the proposed code.

To make it easier to see the diffs, I pushed the current tests with baseline CHECK lines here:
7cc48026bd75 <https://reviews.llvm.org/rG7cc48026bd75b135242e68713e442e9fb206d7e2>

Please rebase and update here, so we will show the differences in the tests.

As mentioned earlier, we should have at least one test with vector types. It could look like this:

  define <2 x i1> @and_or1_op1not_vec(<2 x i1> %a, <2 x i1> %b) {
    %c = call <2 x i1> @gen_v2i1()
    %nota = xor <2 x i1> %a, <i1 true, i1 true>
    %cond = or <2 x i1> %c, %nota
     %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b
     ret <2 x i1> %r
   }

And we must test both of the commuted patterns - it could be this:

  define i1 @and_or2_op1not(i1 %a, i1 %c) {
    %b = call i1 @gen_i1()
    %notc = xor i1 %c, true
    %cond = or i1 %b, %notc
    %r = select i1 %cond, i1 %a, i1 %b
    ret i1 %r
  }


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122152/new/

https://reviews.llvm.org/D122152



More information about the llvm-commits mailing list