If I've done this correctly, then the patch is nearly trivial. :)
Is MachineOperand.isDead() the proper predicate for the EFLAGS operand of an integer math op that we want to reassociate?
This is part of fixing:
https://llvm.org/bugs/show_bug.cgi?id=21768
The intention of the code is checking for a binary operator with EFLAG. When the flag is dead the function returns false.
I see two things to think about: first, why not having a function that makes it explicit incl. an assertion that the third operand actually is an eflag? In the current implementation the assumptions are implicit, so a function would make them more explicit/clear.
Second, the host function checks whether or not a virtual register is defined in \param Inst. It returns true when that is the case. Why doesn't the code check for virtual defs when eflags is dead? So I think its purpose is to eliminate dead instructions in general and binary operators with eflags is perhaps just a special case.