]> git.ipfire.org Git - thirdparty/gcc.git/commit
[Patch match.pd] Fold (A / (1 << B)) to (A >> B)
authorjgreenhalgh <jgreenhalgh@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 22 Jun 2017 08:39:04 +0000 (08:39 +0000)
committerjgreenhalgh <jgreenhalgh@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 22 Jun 2017 08:39:04 +0000 (08:39 +0000)
commitf769c6cfaef32c8a4336a424e0d84c03b4eb8fe5
tree22777f9ae20fbb5df987fa57c59a17698606807b
parent0ee54b9af1156c67da36b7a9ebce31817f013a46
[Patch match.pd] Fold (A / (1 << B)) to (A >> B)

For the testcase in the patch:

  unsigned long
  f2 (unsigned long a, int b)
  {
    unsigned long x = 1UL << b;
    return a / x;
  }

We currently generate an unsigned division and a left shift, where
we could instead generate a right shift.

gcc/

2017-06-21  James Greenhalgh  <james.greenhalgh@arm.com>

* match.pd (A / (1 << B) -> A >> B): New.
* generic-match-head.c: Include optabs-tree.h.
* gimple-match-head.c: Likewise.
* optabs-tree.h (target_supports_op_p): New.
* optabs-tree.c (target_supports_op_p): New.

gcc/testsuite/

2017-06-21  James Greenhalgh  <james.greenhalgh@arm.com>

* gcc.dg/tree-ssa/forwprop-37.c: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249502 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/generic-match-head.c
gcc/gimple-match-head.c
gcc/match.pd
gcc/optabs-tree.c
gcc/optabs-tree.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/forwprop-37.c [new file with mode: 0644]