This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] rotate(X,Z) eq/ne rotate(Y,Z) ---> X eq/ne Y (PR51565)
ClosedPublic

Authored by xbolva00 on Sep 4 2021, 5:50 AM.

Details

Summary
----------------------------------------
define i1 @src(i8 %x, i8 %y, i8 %z) {
%0:
  %f = fshl i8 %x, i8 %x, i8 %z
  %f2 = fshl i8 %y, i8 %y, i8 %z
  %r = icmp eq i8 %f, %f2
  ret i1 %r
}
=>
define i1 @tgt(i8 %x, i8 %y, i8 %z) {
%0:
  %r = icmp eq i8 %x, %y
  ret i1 %r
}
Transformation seems to be correct!

https://alive2.llvm.org/ce/z/qAZp8f

Solves PR51565

Diff Detail

Event Timeline

xbolva00 created this revision.Sep 4 2021, 5:50 AM
xbolva00 requested review of this revision.Sep 4 2021, 5:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 4 2021, 5:50 AM
spatel accepted this revision.Sep 4 2021, 8:18 AM

LGTM - see inline for a nit (so might be worth adding the new function as an NFC pre-commit).

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
3266

This can be an assert, right? We're called only by foldICmpEquality(), so it already checked.

This revision is now accepted and ready to land.Sep 4 2021, 8:18 AM
xbolva00 added inline comments.Sep 4 2021, 8:33 AM
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
3266

Yeah, I was thinking about it too.

xbolva00 updated this revision to Diff 370744.Sep 4 2021, 9:56 AM

Addressed review comments.

LGTM - see inline for a nit (so might be worth adding the new function as an NFC pre-commit).

Sure! Thanks.

This revision was landed with ongoing or failed builds.Sep 4 2021, 9:58 AM
This revision was automatically updated to reflect the committed changes.