On 11/29/23 21:10, Joern Rennecke wrote:
  I originally computed mmask in carry_backpropagate from XEXP (x, 0),
but abandoned that when I realized we also get called for RTX_OBJ
things.  I forgot to adjust the SIGN_EXTEND code, though.  Fixed
in the attached revised patch.  Also made sure to not make inputs
of LSHIFTRT / ASHIFTRT live if the output is dead (and commened
the checks for (mask == 0) in the process).

Something that could be done to futher simplif the code is to make
carry_backpropagate do all the rtx_code-dependent propagation
decisions.  I.e. would have cases for RTX_OBJ, AND, OR, IOR etc
that propagate the mask, and the default action would be to make
the input live (after the check not make any bits in the input
live if the output is dead).

Then we wouldn't need safe_for_live_propagation any more.

Not sure if carry_backpropagate would then still be a suitable name
anymore, though.


tmp.txt

     * ext-dce.cc (carry_backpropagate): Always return 0 when output is dead.  
Fix SIGN_EXTEND input mask.

     * ext-dce.cc: handle vector modes.
* ext-dce.cc: Amend comment to explain how liveness of vectors is tracked.
       (carry_backpropagate): Use GET_MODE_INNER.
       (ext_dce_process_sets): Likewise.  Only apply big endian correction for
       subregs if they don't have a vector mode.
       (ext_cde_process_uses): Likewise.

     * ext-dce.cc: carry_backpropagate: [US]S_ASHIFT fix, handle [LA]SHIFTRT
* ext-dce.cc (safe_for_live_propagation): Add LSHIFTRT and ASHIFTRT.
       (carry_backpropagate): Reformat top comment.
       Add handling of LSHIFTRT and ASHIFTRT.
       Fix bit count for [SU]MUL_HIGHPART.
       Fix pasto for [SU]S_ASHIFT.

     * ext-dce.c: Fixes for carry handling.
* ext-dce.c (safe_for_live_propagation): Handle MINUS.
       (ext_dce_process_uses): Break out carry handling into ..
       (carry_backpropagate): This new function.
       Better handling of ASHIFT.
       Add handling of SMUL_HIGHPART, UMUL_HIGHPART, SIGN_EXTEND, SS_ASHIFT and
       US_ASHIFT.

     * ext-dce.c: fix SUBREG_BYTE test
I haven't done an update in a little while. My tester spun this without the vector bits which I'm still pondering. It did flag one issue.

Specifically on the alpha pr53645.c failed due to the ASHIFTRT handling.


+    case ASHIFTRT:
+      if (CONSTANT_P (XEXP (x, 1))
+         && known_lt (UINTVAL (XEXP (x, 1)), GET_MODE_BITSIZE (mode)))
+       {
+         HOST_WIDE_INT sign = 0;
+         if (HOST_BITS_PER_WIDE_INT - clz_hwi (mask) + INTVAL (XEXP (x, 1))
+             > GET_MODE_BITSIZE (mode).to_constant ())
+           sign = (1ULL << GET_MODE_BITSIZE (mode).to_constant ()) - 1;
+         return sign | (mmask & (mask << INTVAL (XEXP (x, 1))));
+       }
The "-1" when computing the sign bit is meant to apply to the shift count.

Jeff

Reply via email to