[Patch match.pd] Fold (A / (1 << B)) to (A >> B)
authorJames Greenhalgh <james.greenhalgh@arm.com>
Thu, 22 Jun 2017 08:39:04 +0000 (08:39 +0000)
committerJames Greenhalgh <jgreenhalgh@gcc.gnu.org>
Thu, 22 Jun 2017 08:39:04 +0000 (08:39 +0000)
commit71f82be94fad1597696b14c325eed203b75dde70
tree22777f9ae20fbb5df987fa57c59a17698606807b
parenta78f698034a2ab7fabd0d6ca3d35e688670b6d2f
[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.

From-SVN: r249502
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]