https://bugs.llvm.org/show_bug.cgi?id=37610
Bug ID: 37610
Summary: xor %a, C -> xor %a, -1 canonicalization
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedb...@nondot.org
Reporter: lebedev...@gmail.com
CC: llvm-bugs@lists.llvm.org
Clang sometimes generates from
#include <cstdint>
uint8_t and_0(uint32_t cache, uint8_t count) {
return uint8_t(cache) & uint8_t((uint8_t(1) << uint8_t(count)) - uint8_t(1));
}
this
define dso_local zeroext i8 @and_0(unsigned int, unsigned char)(i32, i8
zeroext) local_unnamed_addr #0 {
%3 = zext i8 %1 to i32
%4 = shl i32 1, %3
%5 = add i32 %4, 255
%6 = and i32 %5, %0
%7 = trunc i32 %6 to i8
ret i8 %7
}
Because the constant is not -1, the final code is suboptimal
https://godbolt.org/g/DeY8sr
Should we canonicalize it somehow?
https://rise4fun.com/Alive/sEB
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs