https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123885
Jeffrey A. Law <law at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |smunnangi1 at ventanamicro dot
com
--- Comment #3 from Jeffrey A. Law <law at gcc dot gnu.org> ---
Yea, if we're seeing multiple insns in the conditionally executed block, then
we're going to optimize through the multiple-sets path (if at all) because the
more specialized paths won't trigger as the skipped block isn't "simple".
As it turns out I think some of this problem may be something Shreya has a fix
for in-flight.
Initial RTL generation for the first test looks like this for the conditionally
skipped block:
;; x_3 = x_2(D) << 2;
(insn 9 8 10 (set (reg:DI 138)
(sign_extend:DI (ashift:SI (subreg/s/u:SI (reg/v:DI 135 [ x ]) 0)
(const_int 2 [0x2])))) "j.c":1:34 discrim 1 -1
(nil))
(insn 10 9 11 (set (reg:SI 137 [ x_3 ])
(subreg/s/u:SI (reg:DI 138) 0)) "j.c":1:34 discrim 1 -1
(expr_list:REG_EQUAL (ashift:SI (subreg/s/u:SI (reg/v:DI 135 [ x ]) 0)
(const_int 2 [0x2]))
(nil)))
(insn 11 10 0 (set (reg/v:DI 135 [ x ])
(sign_extend:DI (reg:SI 137 [ x_3 ]))) "j.c":1:34 discrim 1 -1
(nil))
It'd be best if we could clean that up. It's a single gimple statement, so
there's a meaningful chance that could happen. So that's one avenue we could
explore. But that's not what I want to focus on initially.
fwprop will try to propagate insn 9 into insn 10, but that gets rejected as not
profitable. So that's weird and perhaps relevant.
fwprop then propagates insn 10 into 11 resulting in a simple copy. It then
tries to propagate 9 into the 11 (now a copy):
propagating insn 9 into insn 11, replacing:
(set (reg/v:DI 135 [ x ])
(reg:DI 138))
successfully matched this instruction to ashlsi3_extend:
(set (reg/v:DI 135 [ x ])
(sign_extend:DI (ashift:SI (subreg/s/u:SI (reg/v:DI 135 [ x ]) 0)
(const_int 2 [0x2]))))
original cost = 4 (weighted: 2.000000), replacement cost = 8 (weighted:
4.000000); rejecting replacement
So that cost is totally bogus. That should be cost 4. It might still get
rejected for other reasons, but we don't have a chance with the cost model
being this inaccurate.
Anyway, the point is Shreya was in the process of fixing up various bugs in the
cost model before I dragged her into an atomics issue.