https://bugs.llvm.org/show_bug.cgi?id=45694
Bug ID: 45694
Summary: Inconsistent optimization of bit twiddling function
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedb...@nondot.org
Reporter: gabrav...@gmail.com
CC: llvm-bugs@lists.llvm.org
unsigned r1(unsigned a, unsigned b, unsigned mask)
{
return a ^ ((a ^ b) & mask);
}
unsigned r2(unsigned a, unsigned b, unsigned mask)
{
return (~mask & a) | (b & mask);
}
On x86, if `-mbmi` is on, `r1` is translated to `r2`, and then `andn` is used
to generate faster code. If `-mbmi` is off, this optimization does not occur.
Presumably, this would mean that then `r1` is faster than `r2`. I would thus
suggest that in those cases `r2` be optimized to `r1`.
With `-mbmi` : https://godbolt.org/z/CrJboc
Without `-mbmi` : https://godbolt.org/z/kg3vH6
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs