Stephen Canon
2015-Apr-29 19:00 UTC
[LLVMdev] [RFC][Float2Int] Converting (fcmp Pred, x * F, y) to (ICmp ...)
> On Apr 29, 2015, at 2:33 PM, Matt Arsenault <arsenm2 at gmail.com> wrote: > >> On Apr 29, 2015, at 10:06 AM, Silviu Baranga <Silviu.Baranga at arm.com <mailto:Silviu.Baranga at arm.com>> wrote: >> >> Note that dividing by an integer constant should be a cheap operation >> compared to FP multiplication and comparison as this would get lowered to a >> multiply+subtract+shift sequence (and should certainly be true on cores with no >> FP unit) >> > > This is not true on the targets I care about. The integer division (which, even with the division by constant expansion to multiplies with magic constants) would be significantly more expensive.What targets *does* this benefit? Soft-float targets and Cortex-A8? Anyway, both integer and floating-point multiplication and division are monotonic, so it suffices to check the two values of x that bracket y/f. – Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150429/bbf3325e/attachment.html>
Stephen Canon
2015-Apr-29 19:01 UTC
[LLVMdev] [RFC][Float2Int] Converting (fcmp Pred, x * F, y) to (ICmp ...)
> On Apr 29, 2015, at 3:00 PM, Stephen Canon <scanon at apple.com> wrote: > >> On Apr 29, 2015, at 2:33 PM, Matt Arsenault <arsenm2 at gmail.com <mailto:arsenm2 at gmail.com>> wrote: >> >>> On Apr 29, 2015, at 10:06 AM, Silviu Baranga <Silviu.Baranga at arm.com <mailto:Silviu.Baranga at arm.com>> wrote: >>> >>> Note that dividing by an integer constant should be a cheap operation >>> compared to FP multiplication and comparison as this would get lowered to a >>> multiply+subtract+shift sequence (and should certainly be true on cores with no >>> FP unit) >>> >> >> This is not true on the targets I care about. The integer division (which, even with the division by constant expansion to multiplies with magic constants) would be significantly more expensive. > > What targets *does* this benefit? Soft-float targets and Cortex-A8? > > Anyway, both integer and floating-point multiplication and division are monotonic, so it suffices to check the two values of x that bracket y/f.Ah, I see now that y is not a constant. Slightly more subtle. =) I’ll respond later. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150429/d04720d3/attachment.html>
Silviu Baranga
2015-Apr-30 10:32 UTC
[LLVMdev] [RFC][Float2Int] Converting (fcmp Pred, x * F, y) to (ICmp ...)
On Apr 29, 2015, at 2:33 PM, Matt Arsenault <arsenm2 at gmail.com> wrote: This is not true on the targets I care about. The integer division (which, even with the division by constant expansion to multiplies with magic constants) would be significantly more expensive. I agree that we might need a hook to disable this for targets where the transformation is not profitable. On Apr 29, 2015, at 3:00 PM, Stephen Canon <scanon at apple.com> wrote: What targets *does* this benefit? Soft-float targets and Cortex-A8? Regarding profitability: there can be side effects of allowing this transformation to happen. Further operations could get converted from float to int, and integer math is a lot easier to reason about. But that would be hard to model at the moment, so we could only consider the case where we just have something like: (fcmp, (sitofp .. ) , (fmul constant, sitofp)) which (ARM specific) is two moves from core registers to FP registers, two conversions, one multiplication and one comparison. The latency for this (fmov + fcvt + fmul + fcmp) should be large enough even on AArch64 OoO cores to make the transformation profitable. Of course, it depends on the specific core. Thanks, Silviu -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150430/ff2f6ea8/attachment.html>