1. A method of controlling a coalescing of outermost memory transactions, the coalescing causing committing of memory store data to memory for a first transaction to be done at transaction execution (TX) end of a second transaction, the method for generating optimized machine instructions based on an intermediate representation of a program, the method comprising: based on the intermediate representation, generating, by a processor, a first module of optimized non-transactional machine instructions; based on the intermediate representation identifying two atomic tasks to be performed, the two atomic tasks consisting of a first atomic task and a second atomic task, determining whether the two atomic tasks are to be coalesced into a single atomic task; based on determining that the two atomic tasks are not to be coalesced, generating for the first atomic task, a first transaction of transactional machine instructions to be executed and generating for the second atomic task, a second transaction of transactional machine instructions to be executed; and based on determining that the two atomic tasks are to be coalesced, generating for the two atomic tasks, a single coalesced transaction of transactional machine instructions to be executed.