This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/26026] New: power of 2 mod missing optimisation


gcc is using a divide and multiply where it could be using shift/ands:

unsigned long f1(unsigned long x, unsigned long n)
{
        return x % (1UL << n);
}

produces:

f1:
        li 9,1
        slw 9,9,4
        divwu 0,3,9
        mullw 0,0,9
        subf 3,0,3
        blr


-- 
           Summary: power of 2 mod missing optimisation
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: anton at samba dot org
GCC target triplet: powerpc64-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26026


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]