In D129523, it was noted by @spatel that there is are some questionable naked
casts from Instruction to BinaryOperator. Specifically, Sanjay noted
regarding isReassociableOp:
Existing issue: this is awkward - we're dyn_casting to Instruction, but then we nakedly
cast to BinaryOperator on the return. Could this cast to BO directly? There might be
some subtlety with binop constant expressions that needs to be addressed.
Looking into this, it seems to me it's a guaranteed-safe change, and a small
improvement. The result of the dyn_cast is checked for non-null, and when that
passes more elaborate aspects are checked before returning the desired
BinaryOperator on success (and nullptr is returned if any of the checks
fail). Changing the cast directly to BO results in the dyn_cast returning
null in more cases, and so we skip the more elaborate checking which is
guaranteed to have either been pointless, or exposing a bug. (The bug would
only manifest if an inappropriate Opcode were passed (which presumably doesn't
happen). So I'd say the existing code isn't a problem, but this way is better.)
(style) use auto *