We often generate X86ISD::SBB(X, 0) for carry flag arithmetic.
I had tried to create test cases for the ADC equivalent (which often uses the same pattern) but haven't managed to find anything yet.
Differential D57169
[X86] Fold X86ISD::SBB(ISD::SUB(X,Y),0) -> X86ISD::SBB(X,Y) (PR25858) RKSimon on Jan 24 2019, 10:52 AM. Authored by
Details We often generate X86ISD::SBB(X, 0) for carry flag arithmetic. I had tried to create test cases for the ADC equivalent (which often uses the same pattern) but haven't managed to find anything yet.
Diff Detail
Event Timeline
|
This is only valid if the flag result of the SBB is dead. If the sub(X,Y) had a borrow, that information was silently dropped. The SBB output flag should only be calculating the borrow from the result of the subtract minus the C flag. By folding them it would calculate the C flag based on the combined subtraction.
This is the same reason DAGCombiner::visitADDCARRYLike has a check that the ADDCARRY flag result isn't used.