-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Open
Labels
good first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contributellvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmissed-optimization
Description
While we correctly fold this hackers delight ctpop pattern into ctz:
define i4 @src_ctpop(i4 %a0) {
%dec = add i4 %a0, -1
%not = xor i4 %a0, -1
%and = and i4 %dec, %not
%clz = tail call i4 @llvm.ctpop.i4(i4 %and)
ret i4 %clz
}
define i4 @tgt_ctpop(i4 %a0) {
%ctz = tail call i4 @llvm.cttz.i4(i4 %a0, i1 false)
ret i4 %ctz
}
we fail to recognise the related clz pattern:
define i4 @src_lz(i4 %a0) {
%dec = add i4 %a0, -1
%not = xor i4 %a0, -1
%and = and i4 %dec, %not
%clz = tail call i4 @llvm.ctlz.i4(i4 %and, i1 false) ; undef = true is ok as well
%ctz = sub i4 4, %clz
ret i4 %ctz
}
define i4 @tgt_lz(i4 %a0) {
%ctz = tail call i4 @llvm.cttz.i4(i4 %a0, i1 false)
ret i4 %ctz
}
Metadata
Metadata
Assignees
Labels
good first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contributellvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmissed-optimization