Considerations when using Opamp as comparator
This application note answers exactly your question and covers a few less obvious issues associated with incompatibilities that may arise due to the different optimization and expected usage of op-amps and comparators. Give it a read:

https://www.analog.com/en/analog-dialogue/articles/amplifiers-as-comparators.html