On 10/13/25 11:30 AM, Nikita Biryukov wrote:
yes, that looks not ideal indeed. I wonder if checking for sign_extension is
not too specific and we'd rather want something like
"is the single use of the current SET_DEST inside the BB we transform"?
That probably has unintended consequences as well, though...
I agree that it’s difficult to predict the side effects of checking only
for a single use. On the other hand, in the proposed patch this check is
performed only during the first ifcvt pass. We could check for a single
use in the first run, and keep the usual behavior for the second one.
I’m not entirely sure whether this approach might prevent some other
optimizations that run before the second ifcvt pass, but I suspect
it could lead to improvements in certain cases.
The current version of the patch is quite conservative, but it avoids
uncertainty.
What do you think would be the best solution?
If we go with your patch or something similar, I would at least suggest
handling ZERO_EXTEND in a similar manner. I suspect what you're really
after is whether or not the result of the extension is used in the
second set and never again. So you may want to restrict to cases where
the destination of the first set dies in the second set.
Whether or not you extend to other forms extensions may take (shift
pairs, logical and) would seem to be less important. ie, it's unlikely
we'll see targets with zicond, but without zbb.
jeff