From: Uros Bizjak Date: Mon, 26 Mar 2018 19:26:19 +0000 (+0200) Subject: re PR target/85073 ([x86] extra check after BLSR) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2903ad2d599eeba2c32fd2b07b6d697950c84c6e;p=gcc.git re PR target/85073 ([x86] extra check after BLSR) PR target/85073 * config/i386/i386.md (*bmi_blsr__cmp): New insn pattern. (*bmi_blsr__ccz): Ditto. testsuite/ChangeLog: PR target/85073 * gcc.target/i386/pr85073.c: New test. From-SVN: r258864 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a8d9e76b8f5..e2a809c3a17 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-03-26 Uros Bizjak + + PR target/85073 + * config/i386/i386.md (*bmi_blsr__cmp): New insn pattern. + (*bmi_blsr__ccz): Ditto. + 2018-03-26 Tom de Vries PR tree-optimization/85063 diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 2b73e8f6187..5eb9e2fa0e6 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -13774,6 +13774,43 @@ (set_attr "btver2_decode" "double") (set_attr "mode" "")]) +(define_insn "*bmi_blsr__cmp" + [(set (reg:CCZ FLAGS_REG) + (compare:CCZ + (and:SWI48 + (plus:SWI48 + (match_operand:SWI48 1 "nonimmediate_operand" "rm") + (const_int -1)) + (match_dup 1)) + (const_int 0))) + (set (match_operand:SWI48 0 "register_operand" "=r") + (and:SWI48 + (plus:SWI48 + (match_dup 1) + (const_int -1)) + (match_dup 1)))] + "TARGET_BMI" + "blsr\t{%1, %0|%0, %1}" + [(set_attr "type" "bitmanip") + (set_attr "btver2_decode" "double") + (set_attr "mode" "")]) + +(define_insn "*bmi_blsr__ccz" + [(set (reg:CCZ FLAGS_REG) + (compare:CCZ + (and:SWI48 + (plus:SWI48 + (match_operand:SWI48 1 "nonimmediate_operand" "rm") + (const_int -1)) + (match_dup 1)) + (const_int 0))) + (clobber (match_scratch:SWI48 0 "=r"))] + "TARGET_BMI" + "blsr\t{%1, %0|%0, %1}" + [(set_attr "type" "bitmanip") + (set_attr "btver2_decode" "double") + (set_attr "mode" "")]) + ;; BMI2 instructions. (define_expand "bmi2_bzhi_3" [(parallel diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fd7345bd1c9..857870af870 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-26 Uros Bizjak + + PR target/85073 + * gcc.target/i386/pr85073.c: New test. + 2018-03-26 Richard Biener PR testsuite/85066 diff --git a/gcc/testsuite/gcc.target/i386/pr85073.c b/gcc/testsuite/gcc.target/i386/pr85073.c new file mode 100644 index 00000000000..187102d2f86 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr85073.c @@ -0,0 +1,18 @@ +/* PR target/85073 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mbmi" } */ + +int +foo (unsigned x) +{ + int c = 0; + while (x) + { + c += 1; + x = (x - 1) & x; + } + + return c; +} + +/* { dg-final { scan-assembler-times "test" 1 } } */