<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jun 2, 2012, at 11:07 PM, Pete Cooper <<a href="mailto:pete.cooper@gmail.com">pete.cooper@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; "><div style="word-wrap:break-word"><div class="h5"><blockquote type="cite"><p><br>

> +    for (unsigned IO = 0, EO = Instr.getNumOperands(); IO != EO; ++IO) {<br>
> +      const MachineOperand &MO = Instr.getOperand(IO);<br>
> +      if (MO.isRegMask() && MO.clobbersPhysReg(X86::EFLAGS))<br>
> +        return false;<br>
> +      if (!MO.isReg()) continue;<br>
> +<br>
> +      // This instruction modifies or uses EFLAGS before we find a SUB.<br>
> +      // We can't do this transformation.<br>
> +      if (MO.getReg() == X86::EFLAGS)<br>
> +        return false;<br>
> +    }<br></p><p>Please hoist this loop into a helper function. Ideally on MachineInstr so others can use it. It seems generically useful.<br>  </p></blockquote></div></div></blockquote><div>Instead of hoisting this loop, please take a look at MI->modifiesRegister and MI->readsRegister.  I think calling both should match the functionality here.</div></div></blockquote><div><br></div><div>Yep.</div><br><blockquote type="cite"><div class="gmail_quote"><div>  I think MI->readsWritesVirtualRegister matches it even better, but that function specifically mentions virtual registers in its name even though from its implementation I think it would be safe here on the EFLAGS physical register.</div></div></blockquote><div><br></div><div>No, we ought to have an assertion catching abuses like that.</div><div><br></div><div>/jakob</div><div><br></div></div></body></html>