> So I think Kenner's code is trying to prevent having a value in a > SUBREG that is inconsistent with the SUBREG_PROMOTED* flag bits. But > I think it's been unnecessary since Matz's rewrite in 2009.
I couldn't really tell what the rewrite does entirely so I tried creating a case where we would require the SUBREG_PROMOTED_VAR but couldn't come up with any. At least for the most common path through expr I believe I know why: So our case is when we have an SI subreg from a DI reg that is originally a sign-extended SI. Then we NOP-convert the SI subreg from signed to unsigned. We only perform implicit sign extensions therefore we can omit the implicit zero-extension case here. The way the result of the signed->unsigned conversion is used determines whether we can use SUBREG_PROMOTED_VAR. There are two possibilities (1) and (2). void foo (int bar) { unsigned int u = (unsigned int) bar; (1) unsigned long long ul = (unsigned long long) u; As long as the result is used unsigned, we will always perform a zero extension no matter the "Kenner hunk" (because whether the subreg has SRP_SIGNED or !SUBREG_PROMOTED_VAR does not change the need for a zero_extend). (2) long long l = (long long) u; SUBREG_PROMOTED is checked by the following in convert_move: scalar_int_mode to_int_mode; if (GET_CODE (from) == SUBREG && SUBREG_PROMOTED_VAR_P (from) && is_a <scalar_int_mode> (to_mode, &to_int_mode) && (GET_MODE_PRECISION (subreg_promoted_mode (from)) >= GET_MODE_PRECISION (to_int_mode)) && SUBREG_CHECK_PROMOTED_SIGN (from, unsignedp)) The SUBREG_CHECK_PROMOTED_SIGN (from, unsignedp) is decisive as far as I can tell. unsignedp = 1 comes from treeop0 so our "from" (i.e. unsigned int u). With the "Kenner hunk" SUBREG_PROMOTED_VAR is unset, so we don't strip the extension. Without it, SUBREG_PROMOTED_VAR () == SRP_SIGNED which is != unsignedp, so no stripping either. Now there are several other paths that would need auditing as well but at least this one is safe. An interesting test target would be a backend that does implicit zero extensions but as we haven't seen fallout so far chances to find a trigger are slim. Does that make sense? Regards Robin