Does GCC generate Bit Tests (x86 BT)?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












Seaching through the GCC source, I see things like



  • X86_TUNE_USE_BT

  • TARGET_USE_BT

My goal is to get an answer for myself whether or not GCC generates BT, BTS, BTR, and BTC. I started with BT and I found the things above, but I can't find where they are used. Does GCC generate BT instructions at all?



It seems like from this bug report, since resolved, that it now does but where is this instruction shown?










share|improve this question



























    up vote
    0
    down vote

    favorite












    Seaching through the GCC source, I see things like



    • X86_TUNE_USE_BT

    • TARGET_USE_BT

    My goal is to get an answer for myself whether or not GCC generates BT, BTS, BTR, and BTC. I started with BT and I found the things above, but I can't find where they are used. Does GCC generate BT instructions at all?



    It seems like from this bug report, since resolved, that it now does but where is this instruction shown?










    share|improve this question

























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Seaching through the GCC source, I see things like



      • X86_TUNE_USE_BT

      • TARGET_USE_BT

      My goal is to get an answer for myself whether or not GCC generates BT, BTS, BTR, and BTC. I started with BT and I found the things above, but I can't find where they are used. Does GCC generate BT instructions at all?



      It seems like from this bug report, since resolved, that it now does but where is this instruction shown?










      share|improve this question















      Seaching through the GCC source, I see things like



      • X86_TUNE_USE_BT

      • TARGET_USE_BT

      My goal is to get an answer for myself whether or not GCC generates BT, BTS, BTR, and BTC. I started with BT and I found the things above, but I can't find where they are used. Does GCC generate BT instructions at all?



      It seems like from this bug report, since resolved, that it now does but where is this instruction shown?







      gcc intel x86 assembly






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 25 at 1:21

























      asked Sep 25 at 0:46









      Evan Carroll

      4,69493775




      4,69493775




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          Those constants are used in the i386 machine definition file, gcc/config/i386/i386.md; the core instructions themselves are defined here, and a number of combinations are also defined, such as this AND / BTR one.



          To understand how machine definitions are used, see corresponding manual. The overview gives the following summary:




          There are three main conversions that happen in the compiler:



          1. The front end reads the source code and builds a parse tree.

          2. The parse tree is used to generate an RTL insn list based on named instruction patterns.

          3. The insn list is matched against the RTL templates to produce assembler code.



          An instruction definition is used both to generate the RTL instruction in the second conversion, and also to produce the resulting assembly code in the third conversion.



          To see the BT instructions in action:



          #include <stdio.h>
          #include <stdlib.h>

          int main(int argc, char **argv)
          if (argc > 2)
          int x = atoi(argv[1]);
          int n = atoi(argv[2]);
          if (x & (1 << n))
          printf("Set");





          With -O2, that generates a btl for me with GCC 7.3.1.






          share|improve this answer






















          • But where is BTL anywhere in that definition at :8664 that you linked or the machine code for the instruction? Is there a trick to reading this? How would I know what code to write to generate those instructions?
            – Evan Carroll
            Sep 25 at 2:23











          • I think the generation is done from the AST and it's just too scary to make sense out of easy to reverse engineer from the AST tokens what the C looks like. But I would like to know how you go from the define_insn_and_split to the btl token.
            – Evan Carroll
            Sep 25 at 2:34











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f471211%2fdoes-gcc-generate-bit-tests-x86-bt%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote













          Those constants are used in the i386 machine definition file, gcc/config/i386/i386.md; the core instructions themselves are defined here, and a number of combinations are also defined, such as this AND / BTR one.



          To understand how machine definitions are used, see corresponding manual. The overview gives the following summary:




          There are three main conversions that happen in the compiler:



          1. The front end reads the source code and builds a parse tree.

          2. The parse tree is used to generate an RTL insn list based on named instruction patterns.

          3. The insn list is matched against the RTL templates to produce assembler code.



          An instruction definition is used both to generate the RTL instruction in the second conversion, and also to produce the resulting assembly code in the third conversion.



          To see the BT instructions in action:



          #include <stdio.h>
          #include <stdlib.h>

          int main(int argc, char **argv)
          if (argc > 2)
          int x = atoi(argv[1]);
          int n = atoi(argv[2]);
          if (x & (1 << n))
          printf("Set");





          With -O2, that generates a btl for me with GCC 7.3.1.






          share|improve this answer






















          • But where is BTL anywhere in that definition at :8664 that you linked or the machine code for the instruction? Is there a trick to reading this? How would I know what code to write to generate those instructions?
            – Evan Carroll
            Sep 25 at 2:23











          • I think the generation is done from the AST and it's just too scary to make sense out of easy to reverse engineer from the AST tokens what the C looks like. But I would like to know how you go from the define_insn_and_split to the btl token.
            – Evan Carroll
            Sep 25 at 2:34















          up vote
          1
          down vote













          Those constants are used in the i386 machine definition file, gcc/config/i386/i386.md; the core instructions themselves are defined here, and a number of combinations are also defined, such as this AND / BTR one.



          To understand how machine definitions are used, see corresponding manual. The overview gives the following summary:




          There are three main conversions that happen in the compiler:



          1. The front end reads the source code and builds a parse tree.

          2. The parse tree is used to generate an RTL insn list based on named instruction patterns.

          3. The insn list is matched against the RTL templates to produce assembler code.



          An instruction definition is used both to generate the RTL instruction in the second conversion, and also to produce the resulting assembly code in the third conversion.



          To see the BT instructions in action:



          #include <stdio.h>
          #include <stdlib.h>

          int main(int argc, char **argv)
          if (argc > 2)
          int x = atoi(argv[1]);
          int n = atoi(argv[2]);
          if (x & (1 << n))
          printf("Set");





          With -O2, that generates a btl for me with GCC 7.3.1.






          share|improve this answer






















          • But where is BTL anywhere in that definition at :8664 that you linked or the machine code for the instruction? Is there a trick to reading this? How would I know what code to write to generate those instructions?
            – Evan Carroll
            Sep 25 at 2:23











          • I think the generation is done from the AST and it's just too scary to make sense out of easy to reverse engineer from the AST tokens what the C looks like. But I would like to know how you go from the define_insn_and_split to the btl token.
            – Evan Carroll
            Sep 25 at 2:34













          up vote
          1
          down vote










          up vote
          1
          down vote









          Those constants are used in the i386 machine definition file, gcc/config/i386/i386.md; the core instructions themselves are defined here, and a number of combinations are also defined, such as this AND / BTR one.



          To understand how machine definitions are used, see corresponding manual. The overview gives the following summary:




          There are three main conversions that happen in the compiler:



          1. The front end reads the source code and builds a parse tree.

          2. The parse tree is used to generate an RTL insn list based on named instruction patterns.

          3. The insn list is matched against the RTL templates to produce assembler code.



          An instruction definition is used both to generate the RTL instruction in the second conversion, and also to produce the resulting assembly code in the third conversion.



          To see the BT instructions in action:



          #include <stdio.h>
          #include <stdlib.h>

          int main(int argc, char **argv)
          if (argc > 2)
          int x = atoi(argv[1]);
          int n = atoi(argv[2]);
          if (x & (1 << n))
          printf("Set");





          With -O2, that generates a btl for me with GCC 7.3.1.






          share|improve this answer














          Those constants are used in the i386 machine definition file, gcc/config/i386/i386.md; the core instructions themselves are defined here, and a number of combinations are also defined, such as this AND / BTR one.



          To understand how machine definitions are used, see corresponding manual. The overview gives the following summary:




          There are three main conversions that happen in the compiler:



          1. The front end reads the source code and builds a parse tree.

          2. The parse tree is used to generate an RTL insn list based on named instruction patterns.

          3. The insn list is matched against the RTL templates to produce assembler code.



          An instruction definition is used both to generate the RTL instruction in the second conversion, and also to produce the resulting assembly code in the third conversion.



          To see the BT instructions in action:



          #include <stdio.h>
          #include <stdlib.h>

          int main(int argc, char **argv)
          if (argc > 2)
          int x = atoi(argv[1]);
          int n = atoi(argv[2]);
          if (x & (1 << n))
          printf("Set");





          With -O2, that generates a btl for me with GCC 7.3.1.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Sep 25 at 7:34

























          answered Sep 25 at 1:46









          Stephen Kitt

          148k23328395




          148k23328395











          • But where is BTL anywhere in that definition at :8664 that you linked or the machine code for the instruction? Is there a trick to reading this? How would I know what code to write to generate those instructions?
            – Evan Carroll
            Sep 25 at 2:23











          • I think the generation is done from the AST and it's just too scary to make sense out of easy to reverse engineer from the AST tokens what the C looks like. But I would like to know how you go from the define_insn_and_split to the btl token.
            – Evan Carroll
            Sep 25 at 2:34

















          • But where is BTL anywhere in that definition at :8664 that you linked or the machine code for the instruction? Is there a trick to reading this? How would I know what code to write to generate those instructions?
            – Evan Carroll
            Sep 25 at 2:23











          • I think the generation is done from the AST and it's just too scary to make sense out of easy to reverse engineer from the AST tokens what the C looks like. But I would like to know how you go from the define_insn_and_split to the btl token.
            – Evan Carroll
            Sep 25 at 2:34
















          But where is BTL anywhere in that definition at :8664 that you linked or the machine code for the instruction? Is there a trick to reading this? How would I know what code to write to generate those instructions?
          – Evan Carroll
          Sep 25 at 2:23





          But where is BTL anywhere in that definition at :8664 that you linked or the machine code for the instruction? Is there a trick to reading this? How would I know what code to write to generate those instructions?
          – Evan Carroll
          Sep 25 at 2:23













          I think the generation is done from the AST and it's just too scary to make sense out of easy to reverse engineer from the AST tokens what the C looks like. But I would like to know how you go from the define_insn_and_split to the btl token.
          – Evan Carroll
          Sep 25 at 2:34





          I think the generation is done from the AST and it's just too scary to make sense out of easy to reverse engineer from the AST tokens what the C looks like. But I would like to know how you go from the define_insn_and_split to the btl token.
          – Evan Carroll
          Sep 25 at 2:34


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f471211%2fdoes-gcc-generate-bit-tests-x86-bt%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          The Forum (Inglewood, California)

          Palaiologos