[Bug tree-optimization/63586] x+x+x+x -> 4*x in gimple

2016-09-04 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63586

--- Comment #11 from Andrew Pinski  ---
*** Bug 61139 has been marked as a duplicate of this bug. ***

[Bug tree-optimization/63586] x+x+x+x -> 4*x in gimple

2016-08-10 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63586

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||missed-optimization
 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |7.0

--- Comment #10 from Andrew Pinski  ---
Fixed.

[Bug tree-optimization/63586] x+x+x+x -> 4*x in gimple

2016-05-18 Thread kugan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63586

--- Comment #9 from kugan at gcc dot gnu.org ---
Author: kugan
Date: Wed May 18 07:50:05 2016
New Revision: 236359

URL: https://gcc.gnu.org/viewcvs?rev=236359=gcc=rev
Log:
Adding the testcase which was not addaed as part of r236356.
gcc/testsuite/ChangeLog:

2016-05-17  Kugan Vivekanandarajah  

PR middle-end/63586
* gcc.dg/tree-ssa/pr63586-2.c: New test.
* gcc.dg/tree-ssa/pr63586.c: New test.

Added:
trunk/gcc/testsuite/gcc.dg/tree-ssa/pr63586-2.c
trunk/gcc/testsuite/gcc.dg/tree-ssa/pr63586.c

[Bug tree-optimization/63586] x+x+x+x -> 4*x in gimple

2016-05-17 Thread kugan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63586

--- Comment #8 from kugan at gcc dot gnu.org ---
Author: kugan
Date: Wed May 18 00:58:45 2016
New Revision: 236356

URL: https://gcc.gnu.org/viewcvs?rev=236356=gcc=rev
Log:
gcc/testsuite/ChangeLog:

2016-05-17  Kugan Vivekanandarajah  

PR middle-end/63586
* gcc.dg/tree-ssa/pr63586-2.c: New test.
* gcc.dg/tree-ssa/pr63586.c: New test.
* gcc.dg/tree-ssa/reassoc-14.c: Adjust multiplication count.

gcc/ChangeLog:

2016-05-17  Kugan Vivekanandarajah  

PR middle-end/63586
* tree-ssa-reassoc.c (transform_add_to_multiply): New.
(reassociate_bb): Call transform_add_to_multiply.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-14.c
trunk/gcc/tree-ssa-reassoc.c

[Bug tree-optimization/63586] x+x+x+x -> 4*x in gimple

2016-05-05 Thread kugan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63586

kugan at gcc dot gnu.org changed:

   What|Removed |Added

 CC||zboson at zboson dot net

--- Comment #7 from kugan at gcc dot gnu.org ---
*** Bug 68105 has been marked as a duplicate of this bug. ***

[Bug tree-optimization/63586] x+x+x+x -> 4*x in gimple

2015-12-09 Thread kugan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63586

kugan at gcc dot gnu.org changed:

   What|Removed |Added

 CC||vincenzo.innocente at cern dot 
ch

--- Comment #5 from kugan at gcc dot gnu.org ---
*** Bug 61139 has been marked as a duplicate of this bug. ***

[Bug tree-optimization/63586] x+x+x+x -> 4*x in gimple

2015-12-09 Thread kugan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63586

kugan at gcc dot gnu.org changed:

   What|Removed |Added

  Attachment #36908|0   |1
is obsolete||

--- Comment #6 from kugan at gcc dot gnu.org ---
Created attachment 36979
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36979=edit
proposed patch



With the updated pach now we have:

;; Function f4 (f4, funcdef_no=3, decl_uid=4162, cgraph_uid=3, symbol_order=3)

;; 1 loops found
;;
;; Loop 0
;;  header 0, latch 1
;;  depth 0, outer -1
;;  nodes: 0 1 2
;; 2 succs { 1 }
f4 (unsigned int x, unsigned int z, unsigned int k)
{
  unsigned int y;
  unsigned int reassocmul_12;
  unsigned int reassocmul_13;
  unsigned int _14;

  :
  reassocmul_12 = x_2(D) * 4;
  reassocmul_13 = z_6(D) * 3;
  _14 = reassocmul_13 + k_1(D);
  y_10 = _14 + reassocmul_12;
  return y_10;

}


Also, bootstrap and regression testing is clean for x86_64-none-linux-gnu.

[Bug tree-optimization/63586] x+x+x+x -> 4*x in gimple

2015-12-03 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63586

--- Comment #4 from Marc Glisse  ---
(In reply to kugan from comment #2)
> ;; Function f4 (f4, funcdef_no=3, decl_uid=4162, cgraph_uid=3,
> symbol_order=3)
> 
> ;; 1 loops found
> ;;
> ;; Loop 0
> ;;  header 0, latch 1
> ;;  depth 0, outer -1
> ;;  nodes: 0 1 2
> ;; 2 succs { 1 }
> f4 (unsigned int x, unsigned int z, unsigned int k)
> {
>   unsigned int y;
>   unsigned int reassocmul_12;
>   unsigned int reassocmul_13;
>   unsigned int _14;
>   unsigned int _15;
> 
>   :
>   reassocmul_12 = x_2(D) * 3;
>   reassocmul_13 = z_6(D) * 3;
>   _14 = x_2(D) + reassocmul_13;
>   _15 = _14 + reassocmul_12;
>   y_10 = _15 + k_1(D);
>   return y_10;
> 
> }

So the patch fails in this case? It misses the 4th x.


(In reply to kugan from comment #3)
> I think the intention is to have multiplication by power-of-2?

At gimple level, multiplication by any constant would be a good
canonicalization (it can be expanded back to sums later if that's what the
target prefers).

[Bug tree-optimization/63586] x+x+x+x -> 4*x in gimple

2015-12-03 Thread kugan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63586

--- Comment #3 from kugan at gcc dot gnu.org ---
I think the intention is to have multiplication by power-of-2?

[Bug tree-optimization/63586] x+x+x+x -> 4*x in gimple

2015-12-03 Thread kugan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63586

kugan at gcc dot gnu.org changed:

   What|Removed |Added

 CC||kugan at gcc dot gnu.org

--- Comment #2 from kugan at gcc dot gnu.org ---
Created attachment 36908
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36908=edit
proposed patch

With the patch:
unsigned f1(unsigned x){
unsigned y = x + x;
y = y + x;
y = y + x;
y = y + x;
y = y + x;
y = y + x;
y = y + x;
return y;
}
unsigned f2(unsigned x, unsigned z){
unsigned y = x + x;
y = y + x;
y = y + x;
y = y + z;
y = y + z;
y = y + z;
y = y + z;
return y;
}

unsigned f3(unsigned x, unsigned z, unsigned k){
unsigned y = x + x;
y = y + x;
y = y + x;
y = y + z;
y = y + z;
y = y + z;
y = y + k;
return y;
}
unsigned f4(unsigned x, unsigned z, unsigned k){
unsigned y = k + x;
y = y + x;
y = y + x;
y = y + z;
y = y + z;
y = y + z;
y = y + x;
return y;
}


now becomes:

at t7.c.108t.reassoc1 

;; Function f1 (f1, funcdef_no=0, decl_uid=4145, cgraph_uid=0, symbol_order=0)

;; 1 loops found
;;
;; Loop 0
;;  header 0, latch 1
;;  depth 0, outer -1
;;  nodes: 0 1 2
;; 2 succs { 1 }
f1 (unsigned int x)
{
  unsigned int y;
  unsigned int reassocmul_10;

  :
  reassocmul_10 = x_1(D) * 8;
  y_8 = reassocmul_10;
  return y_8;

}



;; Function f2 (f2, funcdef_no=1, decl_uid=4150, cgraph_uid=1, symbol_order=1)

;; 1 loops found
;;
;; Loop 0
;;  header 0, latch 1
;;  depth 0, outer -1
;;  nodes: 0 1 2
;; 2 succs { 1 }
f2 (unsigned int x, unsigned int z)
{
  unsigned int y;
  unsigned int reassocmul_11;
  unsigned int reassocmul_12;

  :
  reassocmul_11 = x_1(D) * 4;
  reassocmul_12 = z_5(D) * 4;
  y_9 = reassocmul_11 + reassocmul_12;
  return y_9;

}



;; Function f3 (f3, funcdef_no=2, decl_uid=4156, cgraph_uid=2, symbol_order=2)

;; 1 loops found
;;
;; Loop 0
;;  header 0, latch 1
;;  depth 0, outer -1
;;  nodes: 0 1 2
;; 2 succs { 1 }
f3 (unsigned int x, unsigned int z, unsigned int k)
{
  unsigned int y;
  unsigned int reassocmul_12;
  unsigned int reassocmul_13;
  unsigned int _14;

  :
  reassocmul_12 = x_1(D) * 4;
  reassocmul_13 = z_5(D) * 3;
  _14 = k_9(D) + reassocmul_13;
  y_10 = _14 + reassocmul_12;
  return y_10;

}



;; Function f4 (f4, funcdef_no=3, decl_uid=4162, cgraph_uid=3, symbol_order=3)

;; 1 loops found
;;
;; Loop 0
;;  header 0, latch 1
;;  depth 0, outer -1
;;  nodes: 0 1 2
;; 2 succs { 1 }
f4 (unsigned int x, unsigned int z, unsigned int k)
{
  unsigned int y;
  unsigned int reassocmul_12;
  unsigned int reassocmul_13;
  unsigned int _14;
  unsigned int _15;

  :
  reassocmul_12 = x_2(D) * 3;
  reassocmul_13 = z_6(D) * 3;
  _14 = x_2(D) + reassocmul_13;
  _15 = _14 + reassocmul_12;
  y_10 = _15 + k_1(D);
  return y_10;

}

[Bug tree-optimization/63586] x+x+x+x - 4*x in gimple

2014-10-20 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63586

Jakub Jelinek jakub at gcc dot gnu.org changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek jakub at gcc dot gnu.org ---
I'd expect reassoc should be the pass to do this.