[Bug tree-optimization/94789] New: Failure to take advantage of shift operand semantics to turn subtraction into negate

gabravier at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Apr 27 08:56:58 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94789

            Bug ID: 94789
           Summary: Failure to take advantage of shift operand semantics
                    to turn subtraction into negate
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

int r(int x, unsigned b)
{
    int const m = CHAR_BIT * sizeof(x) - b;
    return (x << m);
}

`CHAR_BIT * sizeof(x) - b;` can be optimized to `-b`. LLVM does this
transformation, not GCC.

Comparison here : https://godbolt.org/z/5byJ2E


More information about the Gcc-bugs mailing list