search for: pow2

Displaying 20 results from an estimated 27 matches for "pow2".

Did you mean: pow
2013 Apr 24
5
[LLVMdev] Optimize away sqrt in simple cases?
> This is not true. The mathematically correct result for sqrt might not be a representable value in floating point, so rounding may occur between the two steps. In that case, pow2(sqrt(x)) != x. > > --Owen I think what Christoph is saying is that x will always be at least as accurate as pow2(sqrt(x)), so it's only unsafe in so far as one's code is actually depending on an imprecise result. It's not an "as-if" optimization though, so it definitel...
2013 Apr 24
0
[LLVMdev] Optimize away sqrt in simple cases?
On Apr 23, 2013, at 7:15 PM, Stephen Lin <swlin at post.harvard.edu> wrote: >> This is not true. The mathematically correct result for sqrt might not be a representable value in floating point, so rounding may occur between the two steps. In that case, pow2(sqrt(x)) != x. > > I think what Christoph is saying is that x will always be at least as > accurate as pow2(sqrt(x)), so it's only unsafe in so far as one's code > is actually depending on an imprecise result. Giving more-than-expected precision can be just as bad for the user...
2015 Aug 20
2
[RFC] Improving integer divide optimization (related to D12082)
...DAG.getConstant(VT.getScalarSizeInBits() - lg2, DL, > getShiftAmountTy(SGN.getValueType()))); > SDValue ADD = DAG.getNode(ISD::ADD, DL, VT, N0, SRL); > AddToWorklist(SRL.getNode()); > AddToWorklist(ADD.getNode()); // Divide by pow2 > SDValue SRA = DAG.getNode(ISD::SRA, DL, VT, ADD, > DAG.getConstant(lg2, DL, > getShiftAmountTy(ADD.getValueType()))); > > And there’s already a target-specific hook to add a custom implementation (e.g. on PowerPC): > >...
2014 Oct 17
0
Re: CF Card wear optimalisation for ext4
...system can get lost, yes. > Also the value is only available in granularity of 1 GB (plus minus > 512MB) - at least in my case. This is what dumpe2fs is currently using: if (sb->s_kbytes_written) { fprintf(f, "Lifetime writes: "); if (sb->s_kbytes_written < POW2(13)) fprintf(f, "%llu kB\n", sb->s_kbytes_written); else if (sb->s_kbytes_written < POW2(23)) fprintf(f, "%llu MB\n", (sb->s_kbytes_written + POW2(9)) >> 10); else if (sb->s_kbytes_written < POW2(33)) fprintf(f, "%llu GB\n",...
2014 Oct 16
2
Re: CF Card wear optimalisation for ext4
* Andreas Dilger <adilger@dilger.ca> hat geschrieben: > The "lifetime writes" value has not been around forever, so if the > filesystem was originally created and populated on an older kernel > (e.g. using ext3) it would not contain a record of those writes. It was created as stable ext4 in the first place. So only if there was a stable ext4 release which didn't
2017 Sep 13
2
How to add optimizations to InstCombine correctly?
...hould replace the original Instruction in the Worklist. However, I end up in an infinite loop and the Instruction I try to replace gets scheduled again and again. What is wrong in my code? // Replace X * (2^C+/-1) with (X << C) -/+ X APInt Plus1 = *IVal + 1; APInt Minus1 = *IVal - 1; int isPow2 = Plus1.isPowerOf2() ? 1 : Minus1.isPowerOf2() ? -1 : 0; if (isPow2) { APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1; Value *Shl = Builder.CreateShl(Op0, Pow2.logBase2()); return BinaryOperator::Create(isPow2 > 0 ? BinaryOperator::Sub : BinaryOperator::Add, Shl, Op0); } Thanks, Mi...
2015 Aug 20
3
[RFC] Improving integer divide optimization (related to D12082)
...etrokings.com> wrote: > > On Wed, Aug 19, 2015 at 10:58 PM, Mehdi Amini <mehdi.amini at apple.com> wrote: >> >> Isn’t the problem the fact that the patch makes it harder for a target to >> get the generic code to reach its custom hook? >> Now the "cheap pow2 sdiv” is merged with the generic “cheap div” you can’t >> distinguish anymore. >> > > Yes and also the issue of needing more information to make a smart > isIntDivCheap() decision. > > In visitSDIV(), checking looks like this when the denominator is a power of 2. >...
2013 Apr 24
1
[LLVMdev] Optimize away sqrt in simple cases?
...derson wrote: > > On Apr 23, 2013, at 7:15 PM, Stephen Lin <swlin at post.harvard.edu> wrote: > >>> This is not true. The mathematically correct result for sqrt might not be a representable value in floating point, so rounding may occur between the two steps. In that case, pow2(sqrt(x)) != x. >> >> I think what Christoph is saying is that x will always be at least as >> accurate as pow2(sqrt(x)), so it's only unsafe in so far as one's code >> is actually depending on an imprecise result. > > Giving more-than-expected precision can be...
2017 Sep 13
3
How to add optimizations to InstCombine correctly?
...> However, I end up in an infinite loop and the Instruction I try to >> replace gets scheduled again and again. What is wrong in my code? >> >> // Replace X * (2^C+/-1) with (X << C) -/+ X >> APInt Plus1 = *IVal + 1; >> APInt Minus1 = *IVal - 1; >> int isPow2 = Plus1.isPowerOf2() ? 1 : Minus1.isPowerOf2() ? -1 : 0; >> >> if (isPow2) { >> APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1; >> Value *Shl = Builder.CreateShl(Op0, Pow2.logBase2()); >> return BinaryOperator::Create(isPow2 > 0 ? BinaryOperator::Sub : &g...
2015 Aug 19
3
[RFC] Improving integer divide optimization (related to D12082)
Hello LLVM, A recent commit creates the isIntDivCheap() target query. http://reviews.llvm.org/D12082 The current approach has a couple shortcomings. First, when targets decide divide is cheap, the DAGCombiner ignores obvious power-of-2 optimizations. In the targets I know, shifts are cheaper than divides in both speed and size. The target cannot see the value in the isIntDivCheap() call, so
2017 Sep 14
3
How to add optimizations to InstCombine correctly?
...try to > replace gets scheduled again and again. What is wrong in my > code? > > // Replace X * (2^C+/-1) with (X << C) -/+ X > APInt Plus1 = *IVal + 1; > APInt Minus1 = *IVal - 1; > int isPow2 = Plus1.isPowerOf2() ? 1 : Minus1.isPowerOf2() ? > -1 : 0; > > if (isPow2) { > APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1; > Value *Shl = Builder.CreateShl(Op0, Pow2.logBase2()); > return BinaryOperator...
2013 Apr 23
0
[LLVMdev] Optimize away sqrt in simple cases?
...y" unsafe? I see only one > problematic corner case. > > For x >= 0.0 the result cannot lose precision. This is not true. The mathematically correct result for sqrt might not be a representable value in floating point, so rounding may occur between the two steps. In that case, pow2(sqrt(x)) != x. --Owen
2015 Aug 20
2
[RFC] Improving integer divide optimization (related to D12082)
...hdi Amini <mehdi.amini at apple.com <mailto:mehdi.amini at apple.com>> wrote: >>>> >>>> Isn’t the problem the fact that the patch makes it harder for a target to >>>> get the generic code to reach its custom hook? >>>> Now the "cheap pow2 sdiv” is merged with the generic “cheap div” you can’t >>>> distinguish anymore. >>>> >>> >>> Yes and also the issue of needing more information to make a smart >>> isIntDivCheap() decision. >>> >>> In visitSDIV(), checking loo...
2013 Apr 23
2
[LLVMdev] Optimize away sqrt in simple cases?
Hello, Am Dienstag, 23. April 2013, 13:26:19 schrieb Owen Anderson: > That's a pretty seriously unsafe floating point optimization. It could be > done in fast-math mode, but I doubt we currently do it. I just saw this thread and wonder why it's "seriously" unsafe? I see only one problematic corner case. For x >= 0.0 the result cannot lose precision. For x = NaN the
2017 Sep 16
2
How to add optimizations to InstCombine correctly?
...replace gets scheduled again and again. What is wrong in my > > code? > > > > // Replace X * (2^C+/-1) with (X << C) -/+ X > > APInt Plus1 = *IVal + 1; > > APInt Minus1 = *IVal - 1; > > int isPow2 = Plus1.isPowerOf2() ? 1 : Minus1.isPowerOf2() ? > > -1 : 0; > > > > if (isPow2) { > > APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1; > > Value *Shl = Builder.CreateShl(Op0, Pow2.logBase2()); > >...
2017 Sep 19
0
How to add optimizations to InstCombine correctly?
...; wrong in my >> > code? >> > >> > // Replace X * (2^C+/-1) with (X << C) -/+ X >> > APInt Plus1 = *IVal + 1; >> > APInt Minus1 = *IVal - 1; >> > int isPow2 = Plus1.isPowerOf2() ? 1 : >> Minus1.isPowerOf2() ? >> > -1 : 0; >> > >> > if (isPow2) { >> > APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1; >> > Value *Shl = Builde...
2017 Sep 19
0
How to add optimizations to InstCombine correctly?
...; wrong in my >> > code? >> > >> > // Replace X * (2^C+/-1) with (X << C) -/+ X >> > APInt Plus1 = *IVal + 1; >> > APInt Minus1 = *IVal - 1; >> > int isPow2 = Plus1.isPowerOf2() ? 1 : >> Minus1.isPowerOf2() ? >> > -1 : 0; >> > >> > if (isPow2) { >> > APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1; >> > Value *Shl = Builde...
2017 Sep 19
5
How to add optimizations to InstCombine correctly?
...; > code? > >> > > >> > // Replace X * (2^C+/-1) with (X << C) -/+ X > >> > APInt Plus1 = *IVal + 1; > >> > APInt Minus1 = *IVal - 1; > >> > int isPow2 = Plus1.isPowerOf2() ? 1 : > >> Minus1.isPowerOf2() ? > >> > -1 : 0; > >> > > >> > if (isPow2) { > >> > APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1; > >> >...
2005 Jun 29
6
x*x*x*... vs x^n
Hi I have been wondering if there one can speed up calculating small powers of numbers such as x^8 using multiplication. In addition, one can be a bit clever and calculate x^8 using only 3 multiplies. look at this: > f1 <- function(x){x*x*x*x*x*x*x*x} > f2 <- function(x){x^8} > f3 <- function(x){x2 <- x*x;x4 <- x2*x2;return(x4*x4)} [so f1() and f2() and f3() are
2012 Oct 10
2
[LLVMdev] Solicit code review (change to CodeGen)
...6 +14418,7 @@ if (TrueC->getAPIntValue().ult(FalseC->getAPIntValue())) { CC = X86::GetOppositeBranchCondition(CC); std::swap(TrueC, FalseC); + std::swap(TrueOp, FalseOp); } // Optimize C ? 8 : 0 -> zext(setcc(C)) << 3. Likewise for any pow2/0. @@ -14500,6 +14501,45 @@ } } } + + // Handle these cases: + // (select (x != c), e, c) -> select (x != c), e, x), + // (select (x == c), c, e) -> select (x == c), x, e) + // where the c is an integer constant, and the "select" is the combination + // of...