Does GCC generate Bit Tests (x86 BT)?

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Seaching through the GCC source, I see things like
X86_TUNE_USE_BTTARGET_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
add a comment |Â
up vote
0
down vote
favorite
Seaching through the GCC source, I see things like
X86_TUNE_USE_BTTARGET_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
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Seaching through the GCC source, I see things like
X86_TUNE_USE_BTTARGET_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
Seaching through the GCC source, I see things like
X86_TUNE_USE_BTTARGET_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
gcc intel x86 assembly
edited Sep 25 at 1:21
asked Sep 25 at 0:46
Evan Carroll
4,69493775
4,69493775
add a comment |Â
add a comment |Â
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:
- The front end reads the source code and builds a parse tree.
- The parse tree is used to generate an RTL insn list based on named instruction patterns.
- 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.
But where isBTLanywhere 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 thedefine_insn_and_splitto thebtltoken.
â Evan Carroll
Sep 25 at 2:34
add a comment |Â
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:
- The front end reads the source code and builds a parse tree.
- The parse tree is used to generate an RTL insn list based on named instruction patterns.
- 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.
But where isBTLanywhere 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 thedefine_insn_and_splitto thebtltoken.
â Evan Carroll
Sep 25 at 2:34
add a comment |Â
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:
- The front end reads the source code and builds a parse tree.
- The parse tree is used to generate an RTL insn list based on named instruction patterns.
- 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.
But where isBTLanywhere 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 thedefine_insn_and_splitto thebtltoken.
â Evan Carroll
Sep 25 at 2:34
add a comment |Â
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:
- The front end reads the source code and builds a parse tree.
- The parse tree is used to generate an RTL insn list based on named instruction patterns.
- 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.
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:
- The front end reads the source code and builds a parse tree.
- The parse tree is used to generate an RTL insn list based on named instruction patterns.
- 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.
edited Sep 25 at 7:34
answered Sep 25 at 1:46
Stephen Kitt
148k23328395
148k23328395
But where isBTLanywhere 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 thedefine_insn_and_splitto thebtltoken.
â Evan Carroll
Sep 25 at 2:34
add a comment |Â
But where isBTLanywhere 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 thedefine_insn_and_splitto thebtltoken.
â 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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password