[PATCH] D86395: InstCombine transform pattern "(~A & B) ^ A -> (A | B)" added

Jaydeep Chauhan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 07:28:02 PDT 2020


Jac1494 added a comment.

In D86395#2234640 <https://reviews.llvm.org/D86395#2234640>, @spatel wrote:

> The tests should be pre-committed with current CHECK lines (ie, without this patch), so we just see the diffs - and can confirm that the tests actually represent the patterns shown in the test comments.

I have created IR and assembly files like below (without this patch), And I am not getting "%x = add i32 %p, 42 ; thwart complexity-based canonicalization"
But it is there in assembly.

  $ cat test.c
  
  int f(int A,int B)
  {
      return(A ^ (~A & B));
  }
  
  $ clang test.c -S -O1 -emit-llvm
  $ cat test.ll
  ...
  ...
  define dso_local i32 @f(i32 %0, i32 %1) local_unnamed_addr #0 {
    %3 = xor i32 %0, -1
    %4 = and i32 %3, %1
    %5 = xor i32 %4, %0
    ret i32 %5
  }
  ...
  ...
  $ clang test.c -S -O1
  $ cat test.s
  ...
  f:                                      # @f
          .cfi_startproc
  # %bb.0:
          movl    %edi, %eax
          notl    %eax
          andl    %esi, %eax
          xorl    %edi, %eax
          retq
  .Lfunc_end0:
  ...


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

https://reviews.llvm.org/D86395



More information about the llvm-commits mailing list