[llvm-bugs] [Bug 46476] New: Failure to optimize tautological comparisons of comparisons to a single one
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Jun 26 20:09:25 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46476
Bug ID: 46476
Summary: Failure to optimize tautological comparisons of
comparisons to a single one
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: gabravier at gmail.com
CC: llvm-bugs at lists.llvm.org
int f(int a, int b)
{
return (((b != 0) & (a == 0)) | ((a != 0) & (b == 0)));
}
This can be optimized to `(a != 0) ^ (b != 0)`. I originally found this while
compiling this code :
inline bool nand(bool a, bool b)
{
return !(a && b);
}
int f(int a, int b)
{
return nand(nand(b, nand(a, a)), nand(a, nand(b, b)));
}
Which GCC compiles to the above example, and that LLVM optimizes with the
transformation I gave (strangely, LLVM does not seem to optimize the example at
the top of this bug report to the transformed version if directly given the top
example, which is why I'm giving these details as I'm thinking there could be
some kind of UB weirdness or something like that with the transformations here)
--
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/20200627/fc5f63e3/attachment.html>
More information about the llvm-bugs
mailing list