OSDN Git Service

[InstCombine] fold mul of sext bools to 'and'
authorSanjay Patel <spatel@rotateright.com>
Fri, 3 Jul 2020 19:34:55 +0000 (15:34 -0400)
committerSanjay Patel <spatel@rotateright.com>
Fri, 3 Jul 2020 21:28:40 +0000 (17:28 -0400)
commit7fd8af1de052e5bb0e07adba1d2c9e58d1a8f6a4
tree628dd4d6d26f9192957b030a49112bc46e64a08d
parent5504d8b04a572dca9aec9eb21792958700f550c8
[InstCombine] fold mul of sext bools to 'and'

Alive2:
  define i32 @src(i1 %x, i1 %y) {
  %0:
  %zx = sext i1 %x to i32
  %zy = sext i1 %y to i32
  %r = mul i32 %zx, %zy
  ret i32 %r
  }
  =>
  define i32 @tgt(i1 %x, i1 %y) {
  %0:
  %a = and i1 %x, %y
  %r = zext i1 %a to i32
  ret i32 %r
  }
  Transformation seems to be correct!

https://alive2.llvm.org/ce/z/gaPQxA
llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
llvm/test/Transforms/InstCombine/mul.ll