llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[Instcombine] Need to check one-use for the combinations in foldAndOrOfICmps

Open bcl5980 opened this issue 4 years ago • 5 comments

https://godbolt.org/z/Gh39n1YK3

define i1 @src(i8 %x, i8 %y) {
  %cmp1 = icmp ne i8 %x, 0
  %cmp2 = icmp ne i8 %y, 0
  %or = or i1 %cmp1, %cmp2
  %r = call i1 @use(i1 %or, i1 %cmp1, i1 %cmp2)
  ret i1 %r
} 
declare i1 @use(i1, i1, i1)

bcl5980 avatar Nov 25 '22 07:11 bcl5980

It might be better to view this as a missed simplification: https://alive2.llvm.org/ce/z/zvT7eh

rotateright avatar Nov 25 '22 14:11 rotateright

It might be better to view this as a missed simplification: https://alive2.llvm.org/ce/z/zvT7eh

Yeah, this test case is not good enough to show the title. Maybe this one can be better:

define i1 @src(i8 %x, i8 %y) {
  %cmp1 = icmp ne i8 %x, 0
  %cmp2 = icmp ne i8 %y, 0
  %or = or i1 %cmp1, %cmp2
  %r = call i1 @use(i1 %or, i1 %cmp1, i1 %cmp2)
  ret i1 %r
} 
declare i1 @use(i1, i1, i1)

https://godbolt.org/z/Gh39n1YK3

For the simplification you mentioned, this should be more general: https://alive2.llvm.org/ce/z/Li-Eqq

bcl5980 avatar Nov 26 '22 04:11 bcl5980

candidate patch: https://reviews.llvm.org/D138744

ChunyuLiao avatar Nov 26 '22 13:11 ChunyuLiao

candidate patch: https://reviews.llvm.org/D138744

I have already send a patch on D138700 for the pattern spatel mentioned. And this ticket is used for tracking lack one-use.

bcl5980 avatar Nov 26 '22 22:11 bcl5980

Let's proceed with D138700.

ChunyuLiao avatar Nov 29 '22 02:11 ChunyuLiao