This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] cttz(sext(x)) -> cttz(zext(x))
ClosedPublic

Authored by xbolva00 on May 3 2021, 9:06 AM.

Details

Summary
----------------------------------------
define i32 @src(i16 %x, i1 %b) {
%0:
  %z = sext i16 %x to i32
  %p = cttz i32 %z, %b
  ret i32 %p
}
=>
define i32 @tgt(i16 %x, i1 %b) {
%0:
  %z = zext i16 %x to i32
  %p = cttz i32 %z, %b
  ret i32 %p
}
Transformation seems to be correct!

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

Diff Detail

Event Timeline

xbolva00 created this revision.May 3 2021, 9:06 AM
xbolva00 requested review of this revision.May 3 2021, 9:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 3 2021, 9:06 AM

That alive proof only proves cttz(sext(x)) -> cttz(zext(x))

xbolva00 updated this revision to Diff 342425.May 3 2021, 9:36 AM
xbolva00 retitled this revision from [InstCombine] cttz(sext(x)) -> zext(cttz(x)) to [InstCombine] cttz(sext(x)) -> cttz(zext(x)).
xbolva00 updated this revision to Diff 342426.EditedMay 3 2021, 9:39 AM

That alive proof only proves cttz(sext(x)) -> cttz(zext(x))

I meant this one basically as cttz(sext(x)) -> cttz(zext(x)) and cttz(zext(x)) -> zext(cttz(x)) if the 'ZeroIsUndef' parameter is 'true' gives us what we want: cttz(sext(x)) -> zext(cttz(x)) if the 'ZeroIsUndef' parameter is 'true'

Thanks, updated.

xbolva00 updated this revision to Diff 342429.May 3 2021, 9:49 AM
spatel accepted this revision.May 3 2021, 1:00 PM

LGTM

llvm/test/Transforms/InstCombine/cttz.ll
82

Best to fix the test typo as a pre-commit.

This revision is now accepted and ready to land.May 3 2021, 1:00 PM
This revision was automatically updated to reflect the committed changes.