Raul Garcia via llvm-dev
2017-May-18 15:04 UTC
[llvm-dev] Question about demanded bits analysis
Hello All, I am trying to understand the demanded-bits pass. The example in the source code (below) seems quite explicit. In the example, only 16 bits from a 32 bit variable in IR are demanded and therefore the variable is truncated to a 16 bit variable. %1 = add i32 %x, %y %2 = trunc i32 %1 to i16 However I was wondering if for example, the addition demanded, say 18 bits, would this pass generate a i18 integer variable? I have not done the experiment, but I would like to know beforehand if this is something that this pass can do. Regards, Raul. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170518/dd99c196/attachment.html>
Craig Topper via llvm-dev
2017-May-18 16:27 UTC
[llvm-dev] Question about demanded bits analysis
The demanded bits pass is an analysis pass. By itself it won't make any changes to the IR. It is used by other transformation passes that care about this type of information. The main place I know where we look to see if we can perform an operation truncated is in InstCombine. See canEvaluateTruncated in InstCombineCasts.cpp. But I believe we have to be able to completely remove the trunc before we will move it. So we'll need to find something like an earlier sign extend or zero extend that extended from the same type we'd be truncatng to. ~Craig On Thu, May 18, 2017 at 8:04 AM, Raul Garcia via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hello All, > > > I am trying to understand the demanded-bits pass. The example in the > source code (below) seems quite explicit. In the example, only 16 bits from > a 32 bit variable in IR are demanded and therefore the variable is > truncated to a 16 bit variable. > > %1 = add i32 %x, %y%2 = trunc i32 %1 to i16 > > > However I was wondering if for example, the addition demanded, say 18 > bits, would this pass generate a i18 integer variable? I have not done the > experiment, but I would like to know beforehand if this is something that > this pass can do. > > > Regards, > Raul. > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170518/4d0a6368/attachment.html>
James Molloy via llvm-dev
2017-May-18 19:02 UTC
[llvm-dev] Question about demanded bits analysis
Hi, We also use DemandedBits for a similar purpose during loop vectorisation (see computeMinimalBitwidths in VectorUtils.cpp). James On Thu, 18 May 2017 at 17:28, Craig Topper via llvm-dev < llvm-dev at lists.llvm.org> wrote:> The demanded bits pass is an analysis pass. By itself it won't make any > changes to the IR. It is used by other transformation passes that care > about this type of information. > > The main place I know where we look to see if we can perform an operation > truncated is in InstCombine. See canEvaluateTruncated in > InstCombineCasts.cpp. But I believe we have to be able to completely remove > the trunc before we will move it. So we'll need to find something like an > earlier sign extend or zero extend that extended from the same type we'd be > truncatng to. > > ~Craig > > On Thu, May 18, 2017 at 8:04 AM, Raul Garcia via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> Hello All, >> >> >> I am trying to understand the demanded-bits pass. The example in the >> source code (below) seems quite explicit. In the example, only 16 bits from >> a 32 bit variable in IR are demanded and therefore the variable is >> truncated to a 16 bit variable. >> >> %1 = add i32 %x, %y%2 = trunc i32 %1 to i16 >> >> >> However I was wondering if for example, the addition demanded, say 18 >> bits, would this pass generate a i18 integer variable? I have not done the >> experiment, but I would like to know beforehand if this is something that >> this pass can do. >> >> >> Regards, >> Raul. >> >> >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >> > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170518/636eda1e/attachment.html>