[Bug tree-optimization/65307] [4.9 Regression] Incorrect optimization breaks basic arithmetic
maltsevm at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Mar 4 13:44:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65307
Mikhail Maltsev <maltsevm at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |maltsevm at gmail dot com
--- Comment #8 from Mikhail Maltsev <maltsevm at gmail dot com> ---
A simpler testcase:
static inline unsigned cp(unsigned x)
{
return x;
}
unsigned f(unsigned x)
{
return cp(x * 2) * 2 + cp(cp(x * 2) * 3) * 5;
}
$ cat ./test1.c.085t.phiopt2
;; Function f (f, funcdef_no=1, decl_uid=1393, symbol_order=1)
f (unsigned int x)
{
unsigned int _2;
unsigned int _3;
unsigned int _4;
unsigned int _5;
unsigned int _6;
<bb 2>:
_2 = x_1(D) * 2;
_5 = 15;
_3 = _5 + 2;
_4 = _2 * _3;
_6 = _4;
return _6;
}
$ cat ./test1.c.087t.ccp3
;; Function f (f, funcdef_no=1, decl_uid=1393, symbol_order=1)
Pass statistics:
----------------
Immediate_uses:
x_1(D) : --> single use.
_2 = x_1(D) * 2;
_2 : --> single use.
_4 = _2 * _3;
_3 : --> single use.
_4 = _2 * _3;
_4 : --> single use.
_6 = _4;
_5 : --> single use.
_3 = _5 + 2;
_6 : --> single use.
return _6;
.MEM_7(D) : --> single use.
# VUSE <.MEM_7(D)>
return _6;
Adding Destination of edge (0 -> 2) to worklist
Simulating block 2
Visiting statement:
# RANGE [0, 4294967295] NONZERO 0x000000000fffffffe
_2 = x_1(D) * 2;
which is likely CONSTANT
Lattice value changed to CONSTANT 0x00000000000000000 (0x000000000fffffffe).
Adding SSA edges to worklist.
Visiting statement:
# RANGE [0, 4294967295] NONZERO 0x000000000fffffffe
_5 = 15;
which is likely CONSTANT
Lattice value changed to CONSTANT 14. Adding SSA edges to worklist.
Visiting statement:
_3 = _5 + 2;
which is likely CONSTANT
Lattice value changed to CONSTANT 16. Adding SSA edges to worklist.
Visiting statement:
_4 = _2 * _3;
which is likely CONSTANT
Lattice value changed to CONSTANT 0x00000000000000000 (0x000000000ffffffe0).
Adding SSA edges to worklist.
Visiting statement:
# RANGE [0, 4294967295] NONZERO 0x000000000fffffffe
_6 = _4;
Lattice value changed to CONSTANT 0x00000000000000000 (0x000000000ffffffe0).
Adding SSA edges to worklist.
Visiting statement:
# VUSE <.MEM_7(D)>
return _6;
No interesting values produced. Marked VARYING.
Substituting values and folding statements
Folding statement: return _6;
Not folded
Folding statement: _6 = _4;
Not folded
Folding statement: _4 = _2 * _3;
Folded into: _4 = _2 * 16;
Removing dead stmt _3 = 16;
Removing dead stmt _5 = 14;
Folding statement: _2 = x_1(D) * 2;
Not folded
Pass statistics:
----------------
Constants propagated: 1
Statements deleted: 2
f (unsigned intD.4 xD.1392)
{
unsigned intD.4 _2;
unsigned intD.4 _4;
unsigned intD.4 _6;
;; basic block 2, loop depth 0, count 0, freq 10000, maybe hot
;; prev block 0, next block 1, flags: (NEW, REACHABLE)
;; pred: ENTRY [100.0%] (FALLTHRU,EXECUTABLE)
# RANGE [0, 4294967295] NONZERO 0x000000000fffffffe
_2 = x_1(D) * 2;
# RANGE [0, 4294967295] NONZERO 0x000000000ffffffe0
_4 = _2 * 16;
# RANGE [0, 4294967295] NONZERO 0x000000000ffffffe0
_6 = _4;
# VUSE <.MEM_7(D)>
return _6;
;; succ: EXIT [100.0%]
}
More information about the Gcc-bugs
mailing list