This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/77407] New: Optimize integer i / abs (i) into the sign of i
- From: "fw at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 29 Aug 2016 20:04:26 +0000
- Subject: [Bug middle-end/77407] New: Optimize integer i / abs (i) into the sign of i
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77407
Bug ID: 77407
Summary: Optimize integer i / abs (i) into the sign of i
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: fw at gcc dot gnu.org
Target Milestone: ---
I found this gem in some glibc test case:
if (c != 0)
c /= abs (c);
This could turn into:
if (c < 0)
c = -1;
else if (c > 0)
c = 1;
This would eliminate the division and also paper of the bug (the unexpected 1
result for INT_MIN).