* [PATCH, i386]: Fix PR 85073: extra check after BLSR
@ 2018-03-26 20:01 Uros Bizjak
0 siblings, 0 replies; only message in thread
From: Uros Bizjak @ 2018-03-26 20:01 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 400 bytes --]
2018-03-26 Uros Bizjak <ubizjak@gmail.com>
PR target/85073
* config/i386/i386.md (*bmi_blsr_<mode>_cmp): New insn pattern.
(*bmi_blsr_<mode>_ccz): Ditto.
testsuite/ChangeLog:
2018-03-26 Uros Bizjak <ubizjak@gmail.com>
PR target/85073
* gcc.target/i386/pr85073.c: New test.
Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
Committed to mainline SVN.
Uros.
[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 1827 bytes --]
Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md (revision 258856)
+++ config/i386/i386.md (working copy)
@@ -13774,6 +13774,43 @@
(set_attr "btver2_decode" "double")
(set_attr "mode" "<MODE>")])
+(define_insn "*bmi_blsr_<mode>_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" "<MODE>")])
+
+(define_insn "*bmi_blsr_<mode>_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" "<MODE>")])
+
;; BMI2 instructions.
(define_expand "bmi2_bzhi_<mode>3"
[(parallel
Index: testsuite/gcc.target/i386/pr85073.c
===================================================================
--- testsuite/gcc.target/i386/pr85073.c (nonexistent)
+++ testsuite/gcc.target/i386/pr85073.c (working copy)
@@ -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 } } */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-03-26 19:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-26 20:01 [PATCH, i386]: Fix PR 85073: extra check after BLSR Uros Bizjak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).