<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Apr 23, 2014, at 1:50 PM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Tue, Apr 22, 2014 at 6:45 PM, Andrew Trick <<a href="mailto:atrick@apple.com">atrick@apple.com</a>> wrote:<br><blockquote type="cite"><br>On Apr 22, 2014, at 8:19 AM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:<br><br>One of Michael’s early implementations worked completely within the<br>SelectionDAG. We could share that patch if it’s interesting. The goal was to<br>mimic the rest of the llvm.arith.with.overflow intrinsics, including<br>lowering them through the same codegen mechanism.<br><br><br>Right. Those are needed for correct behavior. This is not so it<br>doesn't seem like a good analogy here.<br><br><br>I think the new division intrinsics are needed for correct behavior, as much<br>as the other overflow intrinsics are. The only difference I can see is that<br>architectures typically support reporting overflow on integer add/mul in the<br>form of flags. Whereas with division we need to emit some code to do the<br>checks.<br><br></blockquote><br>Can you show some aspect of any standardized language that can't be<br>handled otherwise?<br></div></blockquote><div><br></div><div>The only language aspect under discussion is integer division. Every standardized language I'm aware of requires some form of check on integer division.</div><div><br></div><div>Either the language is C-based, in which case we need to provide compiler options to achieve sanity: </div><div>-fsanitize=integer-divide-by-zero:</div><div>-fsanitize=signed-integer-overflow</div><div><br></div><div>Or the language requires a check to determine whether to throw an exception.</div><div><br></div><div>Or the language requires a check to determine whether the number needs to be promoted to a different representation.</div><div><br></div><div>Of course, these can all be implemented with explicit checks in the IR. And at IR level, this is exactly the same situation as checking overflow on add/sub/mul. I have argued in the past just as you are now that there is already another way to represent the check. However, LLVM developers are now very heavily using the llvm.arith.with.overflow intrinsics and making the optimizer aware of them, I think we should be consistent. Anyway, implementing explicit checks in the IR (before CodeGenPrepare) tends to make the target independent IR heavily biased toward a particular architecture.</div><div><br></div><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Also, I've not seen the mail you were mentioning on llvm-dev?<br></div></blockquote><div><br></div><div>Yeah. I believe Michael will be posting his proposal on the dev list later today. And the discussion can carry on there.</div><div><br></div>-Andy</div><div><br><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br>-eric</div></blockquote></div><br></body></html>