diff mbox

[i386] : Fix PR 65871, bzhi builtin/intrinsic wrongly assumes bzhi instruction doesn't set the ZF flag

Message ID CAFULd4YoHRuqaESuFc7KXqWPBk_yVtSdQKG_PaBPA4MAk3oW2Q@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak April 29, 2015, 9:07 p.m. UTC
On Wed, Apr 29, 2015 at 9:02 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> Hello!
>
> Attached patch implements a CCZ-only setting pattern for a couple of
> BMI[,2] intrinsics.

These two insns are three operand instructions, and some peephole2
patterns were not prepared for this. Please note that clobbered
register can be different than input registers. Attached patch fixes
this omission.

2015-04-29  Uros Bizjak  <ubizjak@gmail.com>

    PR target/65871
    * config/i386/i386.md (*bmi_bextr_<mode>_cczonly): New pattern.
    (*bmi2_bzhi_<mode>3_1_cczonly): Ditto.
    (setcc+movzbl peephole2): Check also clobbered reg.
    (setcc+andl peephole2): Ditto.

Tested on x86_64-linux-gnu {,-m32} and committed to mainline SVN.

Uros.
diff mbox

Patch

Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md	(revision 222590)
+++ config/i386/i386.md	(working copy)
@@ -11567,7 +11567,9 @@ 
 	(zero_extend (match_dup 1)))]
   "(peep2_reg_dead_p (3, operands[1])
     || operands_match_p (operands[1], operands[3]))
-   && ! reg_overlap_mentioned_p (operands[3], operands[0])"
+   && ! reg_overlap_mentioned_p (operands[3], operands[0])
+   && ! (GET_CODE (operands[4]) == CLOBBER
+	 && reg_mentioned_p (operands[3], operands[4]))"
   [(parallel [(set (match_dup 5) (match_dup 0))
 	      (match_dup 4)])
    (set (strict_low_part (match_dup 6))
@@ -11610,7 +11612,9 @@ 
 	      (clobber (reg:CC FLAGS_REG))])]
   "(peep2_reg_dead_p (3, operands[1])
     || operands_match_p (operands[1], operands[3]))
-   && ! reg_overlap_mentioned_p (operands[3], operands[0])"
+   && ! reg_overlap_mentioned_p (operands[3], operands[0])
+   && ! (GET_CODE (operands[4]) == CLOBBER
+	 && reg_mentioned_p (operands[3], operands[4]))"
   [(parallel [(set (match_dup 5) (match_dup 0))
 	      (match_dup 4)])
    (set (strict_low_part (match_dup 6))