Bug 87203 - Optimize x % constant ==/!= 0
Summary: Optimize x % constant ==/!= 0
Status: RESOLVED DUPLICATE of bug 82853
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-03 11:06 UTC by Jakub Jelinek
Modified: 2018-09-03 11:38 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2018-09-03 11:06:45 UTC
As mentioned in http://duriansoftware.com/joe/Optimizing-is-multiple-checks-with-modular-arithmetic.html , we could optimize unsigned
x % const == 0
or
x % const != 0
into a single (non-highpart) multiplication plus comparison (at least for odd const, for even const we can rotate before comparison if target has cheap rotates, or could test low bits and compare).
Obviously, for power of two const we already emit the best code.
Comment 1 Marc Glisse 2018-09-03 11:31:46 UTC
Dup of PR 82853 ?
Comment 2 Jakub Jelinek 2018-09-03 11:38:23 UTC
Dup indeed.

*** This bug has been marked as a duplicate of bug 82853 ***