On 04/01/2016 04:51 PM, Jakub Jelinek wrote:
On Fri, Apr 01, 2016 at 03:35:19PM +0200, Bernd Schmidt wrote:
On 04/01/2016 03:14 PM, Jakub Jelinek wrote:
As the testcase below shows, we can end up with lots of useless
instructions from multi-word arithmetics.
simplify-rtx.c can optimize x {&,|,^}= {0,-1}, but while
x &= 0 or x {|,^}= -1 are optimized into constants and CSE can handle those
fine, we keep x &= -1 and x {|,^}= 0 in the IL until expansion if x
is a MEM.  There are two issues, one is that cse_insn has for a few years
code that wants to prevent partially overlapping MEM->MEM moves,
but actually doesn't realize that fully overlapping MEM->MEM noop moves
are fine.  And the second one is that on most backends, there are no
MEM->MEM move instructions, so we need to delete the useless insns instead,
because it can't match.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux.
Is this something we want for 6.x or defer for stage1?

It seems like a stage1 thing to me unless it's a regression. But you're in a
better position to make that call.

I guess it can wait for stage1.

+         /* Similarly, lots of targets don't allow no-op
+            (set (mem x) (mem x)) moves.  */
+         else if (n_sets == 1
+                  && MEM_P (trial)
+                  && MEM_P (dest)
+                  && rtx_equal_p (trial, dest)
+                  && !side_effects_p (dest)
+                  && (cfun->can_delete_dead_exceptions
+                      || insn_nothrow_p (insn)))

Looks like this block of code is practically duplicated - I'd prefer a
helper function set_of_equal_mems_removable_p or something. Ok with that
change.

Perhaps instead just set a bool in the second hunk and just test that at the
third hunk's condition?

Also works for me. Or maybe set trial and dest to pc_rtx and merge the new case with the preexisting one. As long as we don't get a big block of duplicated conditions.


Bernd

Reply via email to