[llvm-bugs] [Bug 37610] New: xor %a, C -> xor %a, -1 canonicalization
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon May 28 04:50:09 PDT 2018
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: unassignedbugs at nondot.org
Reporter: lebedev.ri at gmail.com
CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180528/323b2eeb/attachment.html>
More information about the llvm-bugs
mailing list