From Middle English gainsawe, ȝeinsawe, equivalent to gain- + saw (“a saying”). Compare gainsay.
gainsaw (uncountable)