Thread overview
[Issue 5943] New: Power expression optimisation: 2^^unsigned ==> 1<<unsigned
Jan 17, 2013
yebblies
Jun 20, 2013
Kenji Hara
May 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5943

           Summary: Power expression optimisation: 2^^unsigned ==>
                    1<<unsigned
           Product: D
           Version: D2
          Platform: All
        OS/Version: Windows
            Status: NEW
          Keywords: performance
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2011-05-07 05:27:50 PDT ---
Related to bug 5812
I think it's good to have an optimization of 2^^x ==> 1<<x when x is an
unsigned integral or where the compiler can infer x to be a not negative
integral:


import std.math; // currently std.math is needed here
int main(string[] args) {
    return 2 ^^ args.length;
}


Currently it generates:

__Dmain    comdat
L0:        push    EAX
        push    2
        mov    EAX,0Ch[ESP]
        call    near ptr _D3std4math12__T3powTiTkZ3powFNaNbNeikZk
        pop    ECX
        ret

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 17, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=5943


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |yebblies@gmail.com
         AssignedTo|nobody@puremagic.com        |yebblies@gmail.com
         OS/Version|Windows                     |All


--- Comment #1 from yebblies <yebblies@gmail.com> 2013-01-17 13:11:23 EST ---
https://github.com/D-Programming-Language/dmd/pull/1498

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 20, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=5943



--- Comment #2 from github-bugzilla@puremagic.com 2013-06-20 02:35:23 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/50a484a60cc3794281a98c51346fc0dfacfc0f24 Fix Issue 5943 - Power expression optimisation: 2^^unsigned ==> 1<<unsigned

https://github.com/D-Programming-Language/dmd/commit/1f7df6b2b0d0349570d58e92aa5cbceb4572f4c7 Merge pull request #1498 from yebblies/issue5943

Fix Issue 5943 - Power expression optimisation: 2^^unsigned ==> 1<<unsigned

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 20, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=5943


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------