r214385 fixed PR20189, but introduced a regression in the instruction combiner in cases where sub is used for immediates:
with r214385
sub nsw %x, 123 ====> add %x, -123
losing nsw/nuw attributes.
This patch fixes such a behavior for non-binary operations.
The following should work better:
} else { const auto *C = cast<Op1>(Constant); if (!C->isMinSignedValue() && I.hasNoSignedWrap()) Res->setHasNoSignedWrap(true);