/* -O2 -S */ long foo (long x) { return ~0u - x; } for gcc-8 to current master lis 9,0xffff ori 9,9,0xffff rldicl 9,9,0,32 subf 3,3,9 blr a regression from gcc-7 li 9,-1 rldicl 9,9,0,32 subf 3,3,9 blr Both sequences give the same result, this is just a code quality regression. I haven't properly debugged this but I suspect commit 5d3ae76af13
Yes, reverting 5d3ae76af13 cures this PR.
With a patch I'm working on for PR93176, I get the following code (even with the commit below): li 9,-1 rldic 9,9,0,32 subf 3,3,9 blr
Created attachment 49214 [details] proposed patch for the ICEs (wrong PR, sorry)
Comment on attachment 49214 [details] proposed patch for the ICEs (wrong PR, sorry) >diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c >index 76e56b5..2ad5197 100644 >--- a/gcc/bb-reorder.c >+++ b/gcc/bb-reorder.c >@@ -2760,6 +2760,10 @@ duplicate_computed_gotos (function *fun) > if (computed_jump_p (BB_END (bb)) && can_duplicate_block_p (bb)) > changed |= maybe_duplicate_computed_goto (bb, max_size); > >+ /* Some blocks may have become unreachable. */ >+ if (changed) >+ cleanup_cfg (0); >+ > /* Duplicating blocks will redirect edges and may cause hot blocks > previously reached by both hot and cold blocks to become dominated > only by cold blocks. */
So hrm, why did GCC generate lis 0xffff ; ori 0xffff ; rldicl instead of li 0xffff ; oris 0xffff ?
That's easy. rs6000_emit_set_long_const doesn't generate that sequence. Incidentally, a patch I had to generate more constants from li;rldicl also fixes this pr.
and of course, li 0xffff is li -1 which sets all bits.
(In reply to Alan Modra from comment #7) > and of course, li 0xffff is li -1 which sets all bits. Erm, yes. Duh. So that g:5d3ae76af13 splitter should not fire for numbers that fit in 32 bits but that have the high bit of both 16-bit halfs set.
I think that splitter should disappear and rs6000_emit_set_long_const handle all special cases where you might want combinations of two logical instructions before handling the li;rldicl, li;rldicr or any other expansions with rotates.
(In reply to Alan Modra from comment #9) > I think that splitter should disappear and rs6000_emit_set_long_const handle > all special cases where you might want combinations of two logical > instructions before handling the li;rldicl, li;rldicr or any other > expansions with rotates. Yeah, that would be much easier to read and maintain. Good plan.