<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/llvm/lib/Support/DivisionByConstantInfo.cpp, branch users/nico/python-1</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[DivisionByConstantInfo] Use APInt::getLowBitsSet instead of getAllOnes+lshr. NFC</title>
<updated>2024-07-08T05:32:14+00:00</updated>
<author>
<name>Craig Topper</name>
<email>craig.topper@sifive.com</email>
</author>
<published>2024-07-08T05:32:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=13ed3b472b6209ef6f7c5b0ee1eb91e563e01cbc'/>
<id>13ed3b472b6209ef6f7c5b0ee1eb91e563e01cbc</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Use APInt::count{l,r}_{zero,one} (NFC)</title>
<updated>2023-02-20T06:04:47+00:00</updated>
<author>
<name>Kazu Hirata</name>
<email>kazu@google.com</email>
</author>
<published>2023-02-20T06:04:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=f8f3db27565cae8e07c2487f9714a32840c6d548'/>
<id>f8f3db27565cae8e07c2487f9714a32840c6d548</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[Support][SelectionDAG][GlobalISel] Hoist PostShift adjustment for IsAdd into UnsignedDivideUsingMagic.</title>
<updated>2023-01-04T23:18:12+00:00</updated>
<author>
<name>Craig Topper</name>
<email>craig.topper@sifive.com</email>
</author>
<published>2023-01-04T22:17:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=3f749a5d9dfd6111fff77e97ffa4a0f658ae3c41'/>
<id>3f749a5d9dfd6111fff77e97ffa4a0f658ae3c41</id>
<content type='text'>
Instead of doing the adjustment in 3 different places in the code
base, do it inside UnsignedDivideUsingMagic::get.

Differential Revision: https://reviews.llvm.org/D141014
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Instead of doing the adjustment in 3 different places in the code
base, do it inside UnsignedDivideUsingMagic::get.

Differential Revision: https://reviews.llvm.org/D141014
</pre>
</div>
</content>
</entry>
<entry>
<title>[SelectionDAG][GlobalISel] Don't use UnsignedDivisionByConstantInfo for divisor of 1.</title>
<updated>2023-01-04T18:01:15+00:00</updated>
<author>
<name>Craig Topper</name>
<email>craig.topper@sifive.com</email>
</author>
<published>2023-01-04T02:36:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=8bca60fb0aa5f82d32e619d75e65d0dea2472722'/>
<id>8bca60fb0aa5f82d32e619d75e65d0dea2472722</id>
<content type='text'>
The magic algorithm sets IsAdd indication for division by 1 that
the caller had to ignore.

I considered folding the ignore into UnsignedDivisionByConstantInfo,
but we only allow 1 for vectors of mixed visiors. And really what we
want to end up with is undef. Currently, we get to undef via
DemandedElts optimizations using the select instruction. We could
directly emit undef.

Differential Revision: https://reviews.llvm.org/D140940
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The magic algorithm sets IsAdd indication for division by 1 that
the caller had to ignore.

I considered folding the ignore into UnsignedDivisionByConstantInfo,
but we only allow 1 for vectors of mixed visiors. And really what we
want to end up with is undef. Currently, we get to undef via
DemandedElts optimizations using the select instruction. We could
directly emit undef.

Differential Revision: https://reviews.llvm.org/D140940
</pre>
</div>
</content>
</entry>
<entry>
<title>[SelectionDAG][GlobalISel] Move even divisor optimization for division by constant into UnsignedDivideUsingMagic implementation. NFC</title>
<updated>2023-01-04T00:34:13+00:00</updated>
<author>
<name>Craig Topper</name>
<email>craig.topper@sifive.com</email>
</author>
<published>2023-01-04T00:25:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=84daed7fd4077704b0029c8f24ede2edd6d5a0e4'/>
<id>84daed7fd4077704b0029c8f24ede2edd6d5a0e4</id>
<content type='text'>
I've added a bool to UnsignedDivideUsingMagic so we can continue
testing it in the unit test with and without this optimization in
the unit test.

This is a step towards supporting "uncooperative" odd divisors.
See https://ridiculousfish.com/blog/posts/labor-of-division-episode-iii.html

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D140924
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I've added a bool to UnsignedDivideUsingMagic so we can continue
testing it in the unit test with and without this optimization in
the unit test.

This is a step towards supporting "uncooperative" odd divisors.
See https://ridiculousfish.com/blog/posts/labor-of-division-episode-iii.html

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D140924
</pre>
</div>
</content>
</entry>
<entry>
<title>[Support] Fix what I think is an off by 1 bug in UnsignedDivisionByConstantInfo.</title>
<updated>2022-12-29T17:42:50+00:00</updated>
<author>
<name>Craig Topper</name>
<email>craig.topper@sifive.com</email>
</author>
<published>2022-12-29T17:35:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=1490796dd28c80e987a0a9306104141c52022982'/>
<id>1490796dd28c80e987a0a9306104141c52022982</id>
<content type='text'>
The code in Hacker's Delight says
`nc = -1 - (-d)%d;`

But we have
`NC = AllOnes - (AllOnes-D)%D`

The Hacker's Delight code is written for the LeadingZeros==0 case.
`AllOnes - D` is not the same as `-d` from Hacker's Delight.

This patch changes the code to
`NC = AllOnes - (AllOnes+1-D)%D`

This will increment AllOnes to 0 in the LeadingZeros==0 case. This
will make it equivalent to -D. I believe this is also correct for
LeadingZeros&gt;0.

At least for i8, i16, and i32 the only divisor that changes is
((1 &lt;&lt; (BitWidth-1)) | 1). Or 127 for i8, 32769 for i16, and 2147483649
for i32. These are all large enough that the quotient is 0 or 1 so
InstCombine replaces them with an icmp and zext before SelectionDAG.

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D140636
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The code in Hacker's Delight says
`nc = -1 - (-d)%d;`

But we have
`NC = AllOnes - (AllOnes-D)%D`

The Hacker's Delight code is written for the LeadingZeros==0 case.
`AllOnes - D` is not the same as `-d` from Hacker's Delight.

This patch changes the code to
`NC = AllOnes - (AllOnes+1-D)%D`

This will increment AllOnes to 0 in the LeadingZeros==0 case. This
will make it equivalent to -D. I believe this is also correct for
LeadingZeros&gt;0.

At least for i8, i16, and i32 the only divisor that changes is
((1 &lt;&lt; (BitWidth-1)) | 1). Or 127 for i8, 32769 for i16, and 2147483649
for i32. These are all large enough that the quotient is 0 or 1 so
InstCombine replaces them with an icmp and zext before SelectionDAG.

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D140636
</pre>
</div>
</content>
</entry>
<entry>
<title>[NFC] Add exhaustive test coverage for `{Un}signedDivisionByConstantInfo`</title>
<updated>2022-12-25T01:10:32+00:00</updated>
<author>
<name>Roman Lebedev</name>
<email>lebedev.ri@gmail.com</email>
</author>
<published>2022-12-24T21:48:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=066b492b747a7e00f537eab9f0196575522ec285'/>
<id>066b492b747a7e00f537eab9f0196575522ec285</id>
<content type='text'>
Use this wrapper if you want to try brute-forcing wider bit widths:
https://godbolt.org/z/3xGzTM881

I've brute-forced i16 for both signed and unsigned, and we're all good.
As mentioned in https://reviews.llvm.org/D140636
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use this wrapper if you want to try brute-forcing wider bit widths:
https://godbolt.org/z/3xGzTM881

I've brute-forced i16 for both signed and unsigned, and we're all good.
As mentioned in https://reviews.llvm.org/D140636
</pre>
</div>
</content>
</entry>
<entry>
<title>[Support] Use APInt::udivrem in DivisionByConstantInfo. NFC</title>
<updated>2022-12-23T21:33:40+00:00</updated>
<author>
<name>Craig Topper</name>
<email>craig.topper@sifive.com</email>
</author>
<published>2022-12-23T21:33:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=e3774304a2ead0ff2b6478fc30bf47d8e80de66d'/>
<id>e3774304a2ead0ff2b6478fc30bf47d8e80de66d</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[Support] Use inplace APInt operators in DivisionByConstantInfo. NFC</title>
<updated>2022-12-23T08:00:22+00:00</updated>
<author>
<name>Craig Topper</name>
<email>craig.topper@sifive.com</email>
</author>
<published>2022-12-23T06:48:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=1cc48a76eaf1b6b9f59f60e937a9360fff3076bd'/>
<id>1cc48a76eaf1b6b9f59f60e937a9360fff3076bd</id>
<content type='text'>
Reduces the number of temporary APInts that get created and
copy/moved from.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reduces the number of temporary APInts that get created and
copy/moved from.
</pre>
</div>
</content>
</entry>
<entry>
<title>[Support] Move some APInt declarations in DivisionByConstantInfo to their first assignment.</title>
<updated>2022-12-23T06:09:12+00:00</updated>
<author>
<name>Craig Topper</name>
<email>craig.topper@sifive.com</email>
</author>
<published>2022-12-23T05:50:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=1a6310bf87f6497a9448ae5ab13d75b339c758af'/>
<id>1a6310bf87f6497a9448ae5ab13d75b339c758af</id>
<content type='text'>
This uses copy initialization instead of default constructing the
APInts and assigning over them.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This uses copy initialization instead of default constructing the
APInts and assigning over them.
</pre>
</div>
</content>
</entry>
</feed>
