This is an archive of the discontinued LLVM Phabricator instance.

[MIPS GlobalISel] Select count trailing zeros
ClosedPublic

Authored by Petar.Avramovic on Jan 22 2020, 10:12 AM.

Details

Summary

llvm.cttz.<type> intrinsic has additional i1 argument is_zero_undef,
it tells whether zero as the first argument produces a defined result.
G_CTTZ is generated from llvm.cttz.<type> (<type> <src>, i1 false)
intrinsics, clang generates these intrinsics from builtin_ctz and
builtin_ctzll.
G_CTTZ_ZERO_UNDEF comes from llvm.cttz.<type> (<type> <src>, i1 true).
Clang generates such intrinsics as parts of expansion of builtin_ffs
and
builtin_ffsll. It is also traditionally part of and many
algorithms that are now predicated on avoiding zero-value inputs.

Add narrow scalar (algorithm uses G_CTTZ_ZERO_UNDEF) for G_CTTZ.
Lower G_CTTZ and G_CTTZ_ZERO_UNDEF for MIPS32.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJan 22 2020, 10:12 AM

Add check that OrigType is scalar and NarrowTy == OrigType/2. Fix build unmerge.

Add comment in narrow scalar for cttz.

This revision is now accepted and ready to land.Jan 23 2020, 6:31 AM
This revision was automatically updated to reflect the committed changes.