This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/63586] x+x+x+x -> 4*x in gimple
- From: "kugan at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 03 Dec 2015 22:37:41 +0000
- Subject: [Bug tree-optimization/63586] x+x+x+x -> 4*x in gimple
- Auto-submitted: auto-generated
- References: <bug-63586-4 at http dot gcc dot gnu dot org/bugzilla/>
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&action=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;
<bb 2>:
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;
<bb 2>:
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;
<bb 2>:
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;
<bb 2>:
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;
}