This patch extends the existing if combining canonicalization to also handle the case where a value returned by the first if is used within the body of the second if.
This patch also extends if combining to support if's whose conditions are logical negations of each other.
Something like rewriter.replaceOpWithinBlock or rewriter.replaceOpWithIf should work here.