Introduce two intrinsics which are then lowered in the backend to AssertZExt nodes. These can be inserted into the IR when the compiler knows that the given operand is already a zero extended i8 or i16.
Details
Diff Detail
Event Timeline
These clearly shouldn't be target-specific.
Usually, if there isn't loop involved, SelectionDAGBuilder can figure out leading zeros itself by using computeKnownBits on the live-out values. Are you sure you can't solve whatever issue you're looking at by improving ARMTargetLowering::computeKnownBitsForTargetNode?
Yes exactly, I would like to use these for loops. In ARMCodeGenPrepare I need to insert truncs to keep the IR legal, although I've already proved that the value is already zero extended. In those cases I want to use these intrinsics to carry that knowledge through. So it's not trying to work around the lack of info of target specific nodes. Another idea I wondered about was adding flags to instructions, but that seems far more intrusive.
And what would I need to do about testing for a generic intrinsic? Add to BitCode/compatibility-6.0.ll test and just keep this codegen one too?
Add to BitCode/compatibility-6.0.ll test and just keep this codegen one too?
Yes, that's probably enough for basic testing...
But a portable intrinsic probably also needs to go through a design discussion on llvmdev, so it's clear this is the right design: how is this different from other similar constructs like !range metadata and llvm.assert, is there some way to communicate this information to SelectionDAG in some way that doesn't involve mutating the IR, how can we generalize this, etc.
Or maybe we could keep this target-specific, with a different name, with the justification that this isn't really an IR extension, just an implementation detail of the code generator to work around SelectionDAG limitations. We already have a sort of notion that when IR is passed to the code generator, the code generator can modify IR in ways that might not make sense to general IR passes. For example, llvm.ppc.mtctr is an intrinsic only used by PPCCTRLoops. But in that case we should use a name that makes it clear it isn't a general-purpose intrinsic usable by frontends or IR optimizations.
To try to make it clear that these are not user facing intrinsics, I've renamed them to arm.codegen.zeroext