[llvm-bugs] [Bug 52094] New: [InstCombine] failed to set/use popcount range metadata
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Oct 6 10:17:17 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=52094
Bug ID: 52094
Summary: [InstCombine] failed to set/use popcount range
metadata
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: spatel+llvm at rotateright.com
CC: llvm-bugs at lists.llvm.org
https://alive2.llvm.org/ce/z/c2tUxf
define i32 @src(i32 %0) {
%2 = and i32 %0, 15
%3 = tail call i32 @llvm.ctpop.i32(i32 %2)
%4 = and i32 %3, 5
%5 = icmp eq i32 %4, 1
%6 = zext i1 %5 to i32
ret i32 %6
}
define i32 @tgt(i32 %0) {
%2 = and i32 %0, 15
%3 = tail call i32 @llvm.ctpop.i32(i32 %2)
%4 = and i32 %3, 1
ret i32 %4
}
declare i32 @llvm.ctpop.i32(i32) #2
---------------------------------------------------------------------------
We fail to recognize this as a parity check which could lead to far worse
codegen (especially for a target that does not have a popcount instruction):
IR corresponds to source like this:
int xor4_popcount(int num) {
int masknum = num & 0xf;
int pop = __builtin_popcount(masknum);
return pop == 1 || pop == 3;
}
This example is derived from the post-commit discussion in:
https://reviews.llvm.org/D110170
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211006/3e61109b/attachment.html>
More information about the llvm-bugs
mailing list