[Issue 22116] New: optimize values based on prior comparisons

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jul 11 18:18:50 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=22116

          Issue ID: 22116
           Summary: optimize values based on prior comparisons
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: bugzilla at digitalmars.com

Consider:

    bool b = (a == 3) ? a : 0;

which can be replaced with:

    bool b = (a == 3);

The idea is to do data flow analysis and note that `a` has the value of 3 or
!=3 when on a leg of a conditional code path.

--


More information about the Digitalmars-d-bugs mailing list