https://bugs.llvm.org/show_bug.cgi?id=50167
Bug ID: 50167
Summary: Avoid unnecessary widening
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
>From Reddit:
void scale(uint8_t *__restrict dst, const uint8_t *__restrict src1) {
for(int i=0; i<64; ++i) {
int v = src1[i] * 3;
if (v > 255)
v = 255;
dst[i] = (uint8_t)v;
}
}
"Clang manages a decent attempt and recognizes that it can reduce the
multiplication to adds, but fails to stay at byte width and ends up widening
all the way to int, which seriously hurts throughput. It seems that the
optimizer failed to track value ranges properly as it could have stayed at
short (16-bit), and the narrowing also has an unnecessary clamp that the
packuswb instruction already provides."
https://gcc.godbolt.org/z/85f6YYEq3
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs