The goal of this patch is to optimize away the test instruction in the following pattern
%reg = and ... EFLAGS set
... EFLAGS not changed.
%extended_reg = subreg_to_reg 0, %reg, %subreg.sub_index. EFLAGS not changed
testrr %extended_reg, %extended_reg, implicit-def $eflags. This could be optimized away.
Before this patch, the optimization wasn't carried out, since extended_reg is defined by SUBREG_TO_REG, which is not handled by isDefConvertible in X86InstrInfo.cpp.
The implementation optimize away the test if the bits used by TEST readers are already set by AND.
I don't know if this is necessary. If the SUBREG_TO_REG was used, the sign bit of the full 64 bit value was provably zero during SelectionDAG. I hope any branch, setcc, cmov would have been folded away based on it.
Can't we just set NoSignFlag=true?