Hello! Another pattern that seems useful.
2015-05-05 Uros Bizjak <ubiz...@gmail.com> PR target/65871 * config/i386/i386.md (*bmi_andn_<mode>_ccno): New pattern. testsuite/ChangeLog: 2015-05-05 Uros Bizjak <ubiz...@gmail.com> PR target/65871 * gcc.target/i386/pr65871-3.c: New test. Teste on x86_64-linux-gnu {,-m32} and committed to mainline SVN. Uros.
Index: config/i386/i386.md =================================================================== --- config/i386/i386.md (revision 222774) +++ config/i386/i386.md (working copy) @@ -12565,11 +12564,25 @@ (set_attr "btver2_decode" "direct, double") (set_attr "mode" "<MODE>")]) +(define_insn "*bmi_andn_<mode>_ccno" + [(set (reg FLAGS_REG) + (compare + (and:SWI48 + (not:SWI48 (match_operand:SWI48 1 "register_operand" "r,r")) + (match_operand:SWI48 2 "nonimmediate_operand" "r,m")) + (const_int 0))) + (clobber (match_scratch:SWI48 0 "=r,r"))] + "TARGET_BMI && ix86_match_ccmode (insn, CCNOmode)" + "andn\t{%2, %1, %0|%0, %1, %2}" + [(set_attr "type" "bitmanip") + (set_attr "btver2_decode" "direct, double") + (set_attr "mode" "<MODE>")]) + (define_insn "bmi_bextr_<mode>" [(set (match_operand:SWI48 0 "register_operand" "=r,r") (unspec:SWI48 [(match_operand:SWI48 1 "nonimmediate_operand" "r,m") - (match_operand:SWI48 2 "register_operand" "r,r")] - UNSPEC_BEXTR)) + (unspec:SWI48 [(match_operand:SWI48 1 "nonimmediate_operand" "r,m") + (match_operand:SWI48 2 "register_operand" "r,r")] + UNSPEC_BEXTR)) (clobber (reg:CC FLAGS_REG))] "TARGET_BMI" "bextr\t{%2, %1, %0|%0, %1, %2}" Index: testsuite/gcc.target/i386/pr65871-3.c =================================================================== --- testsuite/gcc.target/i386/pr65871-3.c (revision 0) +++ testsuite/gcc.target/i386/pr65871-3.c (working copy) @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mbmi" } */ + +int foo (int x, int y) +{ + if (~x & y) + return 1; + + return 0; +} + +int bar (int x, int y) +{ + if ((~x & y) > 0) + return 1; + + return 0; +} + +/* { dg-final { scan-assembler-not "test" } } */