llvm currently turns the following code
void foo1(int a, char *p) {
int t = a & 0xfd; *p = t;
}
into these instructions:
movz w8, #253
and w8, w0, w8
strb w8, [x1]
This can be done using just two instructions, since we don't care what the upper 24-bits of the "and" instruction are.
and w8, w0, 0xfffffffd
strb w8, [x1]
This patch adds a target hook to TargetLowering::TargetLoweringOpt and overrides it in the AArch64 backend to sign-extend an immediate operand if the upper bits are not demanded and sign-extending enables folding the immediate into the instruction.
This optimization speeds up 253.perlbmk by 5%.
Add more detail on when this is called and what the parameters are?