If the sub doesn't overflow in the original type we can move it above the sext/zext.

This is similar to what we do for add. The overflow checking for sub is currently weaker than add, so the test cases are constructed for what is supported.

Differential D52075
[InstCombine] Support (sub (sext x), (sext y)) --> (sext (sub x, y)) and (sub (zext x), (zext y)) --> (zext (sub x, y)) craig.topper on Sep 14 2018, 12:01 AM.
Details If the sub doesn't overflow in the original type we can move it above the sext/zext. This is similar to what we do for add. The overflow checking for sub is currently weaker than add, so the test cases are constructed for what is supported.
Diff Detail - Repository
- rL LLVM
## Event TimelineComment Actions Logic seems right, but we already had a big pile of repeated code. Comment Actions LGTM - but please add at least one negative test where the math actually could overflow, so we verify that the value tracking is in place. |