[CodeGen] RFC Changing the default operation action for CTLZ_ZERO_UNDEF/CTTZ_ZERO_UNDEF to Expand

I’d like to change the default operation action for CTLZ_ZERO_UNDEF and CTTZ_ZERO_UNDEF to Expand in TargetLoweringBase. This will make LegalizeDAG automatically turn them into CTLZ and CTTZ.

For the in-tree targets, only AMDGPU and X86 have cases where these instructions should be the current default value of Legal. There a few cases where targets set them to Custom. But most targets set them to Expand to have LegalizeDAG convert them.

This change would allow us to remove all the setOperationAction calls to make them Expand on most targets and adds a few calls to setOperationAction on X86 and AMDGPU to make them Legal again for certain cases.

This could affect out of tree targets, but its easy to fix any out of tree targets that rely on the current default Legal value. Any out of tree targets that were already setting them to Expand will to continue to work, but just have redundant code.

Any objections?

LGTM, although I suspect others’ opinions are more relevant than mine…

Hi Craig,

I'm assuming that change will consider the legal types in the target.
AArch64 sets both 32 and 64 to Expand, while ARM only sets 32, for
obvious reasons.

This seems like an NFC, so LGTM. :slight_smile: