[llvm-bugs] [Bug 52190] New: Missed optimization for ashr with zero or all ones as LHS
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Oct 15 15:39:50 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=52190
Bug ID: 52190
Summary: Missed optimization for ashr with zero or all ones as
LHS
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: david.bolvansky at gmail.com
CC: llvm-bugs at lists.llvm.org
LLVM does optimize these cases - remove ashr:
int ok(__int128 f, int g)
{
return (f >> 127) >> g;
}
int ok2(int f, int g)
{
return (f >> 31) >> g;
}
int ok3(int f, int g)
{
if (f == 0 || f == 1)
return (-f) >> g;
__builtin_unreachable();
}
But not these:
int bad1(int f, int g)
{
if (f == 0 || f == -1)
return f >> g;
__builtin_unreachable();
}
int bad2(int f, int g)
{
if (f == 0 || f == 1)
return (f-1) >> g;
return 0;
}
int bad3(int f, int g)
{
if (f == 6 || f == 7)
return (f-7) >> g;
__builtin_unreachable();
}
https://godbolt.org/z/4P8vWcnWj
--
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/20211015/449de1c5/attachment.html>
More information about the llvm-bugs
mailing list