aboutsummaryrefslogtreecommitdiff
path: root/libcpp/directives.cc
diff options
context:
space:
mode:
authorXi Ruoyao <xry111@xry111.site>2022-07-06 13:45:55 +0800
committerXi Ruoyao <xry111@xry111.site>2022-07-10 11:36:11 +0800
commita5d3826f7648c4c7763dba8882e6722deae0c116 (patch)
tree4b69cbd80c7182ef0e5d1e116f0fb16f2ad46cbe /libcpp/directives.cc
parent1fa42d62140b56589771eb3d46f89c810bfc8e0a (diff)
downloadgcc-a5d3826f7648c4c7763dba8882e6722deae0c116.zip
gcc-a5d3826f7648c4c7763dba8882e6722deae0c116.tar.gz
gcc-a5d3826f7648c4c7763dba8882e6722deae0c116.tar.bz2
loongarch: add alternatives for idiv insns to improve code generation
Currently in the description of LoongArch integer division instructions, the output is marked as earlyclobbered ('&'). It's necessary when loongarch_check_zero_div_p() because clobbering operand 2 (divisor) will make the checking for zero divisor impossible. But, for -mno-check-zero-division (the default of GCC >= 12.2 for optimized code), the output is not earlyclobbered at all. And, the read of operand 1 only occurs before clobbering the output. So we make three alternatives for an idiv instruction: * (=r,r,r): For -mno-check-zero-division. * (=&r,r,r): For -mcheck-zero-division. * (=&r,0,r): For -mcheck-zero-division, to explicitly allow patterns like "div.d $a0, $a0, $a1". gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_check_zero_div_p): Remove static, for use in the machine description file. * config/loongarch/loongarch-protos.h: (loongarch_check_zero_div_p): Add prototype. * config/loongarch/loongarch.md (enabled): New attr. (*<optab><mode>3): Add (=r,r,r) and (=&r,0,r) alternatives for idiv. Conditionally enable the alternatives using loongarch_check_zero_div_p. (<optab>di3_fake): Likewise. gcc/testsuite/ChangeLog: * gcc.target/loongarch/div-1.c: New test. * gcc.target/loongarch/div-2.c: New test. * gcc.target/loongarch/div-3.c: New test.
Diffstat (limited to 'libcpp/directives.cc')
0 files changed, 0 insertions, 0 deletions