Legalize and select G_ABS so that we can use llvm.abs intrinsic
This has to be a signext, so the wide value gets the same sign as the narrow value. Otherwise the wide G_ABS might behave differently from the narrow G_ABS.
|773 ↗||(On Diff #345075)|
Don't bother with this pattern, just make G_ABS s16 only legal on subtargets that have 16 bit instructions.
Typo "sgpr" in lots of function names.
Not really related to your patch, but this sequence needs cleaning up. The s_and is redundant, and the s_cmp just computes the same scc value that s_add computed in the first place.
Merge this with the G_SMIN, G_SMAX, G_UMIN, G_UMAX handling above, which is slightly better because it will widen e.g. s8 to s16 and s24 to s32, instead of lowering them.
Same here, mege it with the slightly better G_SMIN, G_SMAX, G_UMIN, G_UMAX handling above.
I would hope that you could call the LegalizerHelper for this part. However I see the lower() implementation hardcodes one path and doesn't provide the helpers for the multiple options. Ideally we could clean that up
- Added legalizeABS() as a custom lowering to be used by RegBankSelect.
I don't see a way to add multiple paths to already existing lower() for G_ABS and control which one to use. Not sure if this is the cleaner way of doing it that you had in mind.
- Add lowerAbsToMaxSub as a new LegalizerHelper function to be used by AMDGPURegisterBankInfo
- Move default code for lowering G_ABS to lowerAbs to make it more clear there are two ways of legalizing.
Maybe rename lowerAbs to lowerAbsToAshrAddXor or lowerAbsToAddXor?