On 11/16/2015 03:07 PM, Kyrill Tkachov wrote:
I've explained in the comments in the patch what's going on but the
short version is trying to change the destination of a defining insn
that feeds into an extend insn is not valid if the defining insn
doesn't feed directly into the extend insn. In the ree pass the only
way this can happen is if there is an intermediate conditional move
that the pass tries to handle in a special way. An equivalent fix
would have been to check on that path (when copy_needed in
combine_reaching_defs is true) that the state->copies_list vector
(that contains the conditional move insns feeding into the extend
insn) is empty.
I ran this through gdb, and I think I see what's going on. For
reference, here's a comment from the source:
/* Considering transformation of
(set (reg1) (expression))
...
(set (reg2) (any_extend (reg1)))
into
(set (reg2) (any_extend (expression)))
(set (reg1) (reg2))
... */
I was thinking that another possible fix would be to also check
!reg_used_between_p for reg1 to ensure it's not used. I'm thinking this
might be a little clearer - what is your opinion?
The added comment could lead to some confusion since it's placed in
front of an existing if statement that also tests a different condition.
Also, if we go with your fix,
+ || !reg_overlap_mentioned_p (tmp_reg, SET_SRC (PATTERN (cand->insn))))
Shouldn't this really be !rtx_equal_p?
Bernd