[PATCH] D107170: [InstCombine] canonicalize cmp-of-bitcast-of-vector-cmp to use zero constant

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 31 09:33:27 PDT 2021


lebedev.ri added a comment.

Hm, to be noted, this is still only a subpattern, with further generalization being: (https://alive2.llvm.org/ seems to be down)

  define i1 @src(i8 %x, i8 %y) {
    %nx = xor i8 %x, -1
    %r = icmp eq i8 %nx, %y
    ret i1 %r
  }
  
  define i1 @tgt(i8 %x, i8 %y) {
    %ny = xor i8 %y, -1
    %r = icmp eq i8 %x, %ny
    ret i1 %r
  }

  ----------------------------------------
  define i1 @src(i8 %x, i8 %y) {
  %0:
    %nx = xor i8 %x, 255
    %r = icmp eq i8 %nx, %y
    ret i1 %r
  }
  =>
  define i1 @tgt(i8 %x, i8 %y) {
  %0:
    %ny = xor i8 %y, 255
    %r = icmp eq i8 %x, %ny
    ret i1 %r
  }
  Transformation seems to be correct!

and

  define i8 @src(<2 x i4> %x) {
    %s = bitcast <2 x i4> %x to i8
    %r = xor i8 %s, -1
    ret i8 %r
  }
  
  define i8 @tgt(<2 x i4> %x) {
    %nx = xor <2 x i4> %x, <i4 -1, i4 -1>
    %r = bitcast <2 x i4> %nx to i8
    ret i8 %r
  }

  ----------------------------------------
  define i8 @src(<2 x i4> %x) {
  %0:
    %s = bitcast <2 x i4> %x to i8
    %r = xor i8 %s, 255
    ret i8 %r
  }
  =>
  define i8 @tgt(<2 x i4> %x) {
  %0:
    %nx = xor <2 x i4> %x, { 15, 15 }
    %r = bitcast <2 x i4> %nx to i8
    ret i8 %r
  }
  Transformation seems to be correct!


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

https://reviews.llvm.org/D107170



More information about the llvm-commits mailing list