[llvm-dev] Signed Division and InstCombine
Dilan Manatunga via llvm-dev
llvm-dev at lists.llvm.org
Tue May 31 16:19:29 PDT 2016
Ohh, duh. Just did the math in my head. All makes sense now. Probably had
the same thought process you were having when I initially thought it should
Thanks for the quick responses.
On Tue, May 31, 2016 at 4:12 PM Tim Northover <t.p.northover at gmail.com>
> On 31 May 2016 at 16:02, Dilan Manatunga <manatunga at gmail.com> wrote:
> > Just to verify, a 16-bit divion of INT16_MIN by -1 results in INT16_MIN
> > again?
> No, "sdiv i16 -32768, -1" is undefined behaviour. The version with an
> "sext" and "trunc" avoids the undefined behaviour and does return
> > If the issue only occurs in this case, why aren't there checks to see if
> > can simplify sdiv in cases where we know that numerator is not INT16_MIN
> > the denominator is not -1. For example, we could simplify divides
> > one operand constants. Is it because this case is most likely rare?
> It's probably just that no-one has bothered to implement it, I'd
> actually expect the code to be reasonably common from C compilation.
> Another factor is that RISC CPUs mostly won't care (they tend to only
> have natural width division anyway), so that removes a large swathe of
> people who might be interested.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev