diff mbox

[i386] Fix PR64003

Message ID 20141208105947.GA34955@msticlxl57.ims.intel.com
State New
Headers show

Commit Message

Ilya Enkovich Dec. 8, 2014, 10:59 a.m. UTC
On 08 Dec 11:30, Ilya Enkovich wrote:
> 2014-12-07 12:51 GMT+03:00 Richard Sandiford <rdsandiford@googlemail.com>:
> > Ilya Enkovich <enkovich.gnu@gmail.com> writes:
> >> diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
> >> index 88435d6..9019ed8 100644
> >> --- a/gcc/config/i386/i386.md
> >> +++ b/gcc/config/i386/i386.md
> >> @@ -10958,6 +10958,24 @@
> >>  ;; Basic conditional jump instructions.
> >>  ;; We ignore the overflow flag for signed branch instructions.
> >>
> >> +(define_insn "*jcc_1_bnd"
> >> +  [(set (pc)
> >> +     (if_then_else (match_operator 1 "ix86_comparison_operator"
> >> +                                   [(reg FLAGS_REG) (const_int 0)])
> >> +                   (label_ref (match_operand 0))
> >> +                   (pc)))]
> >> +  "TARGET_MPX && ix86_bnd_prefixed_insn_p (insn)"
> >> +  "bnd %+j%C1\t%l0"
> >> +  [(set_attr "type" "ibr")
> >> +   (set_attr "modrm" "0")
> >> +   (set (attr "length")
> >> +        (if_then_else (and (ge (minus (match_dup 0) (pc))
> >> +                               (const_int -126))
> >> +                           (lt (minus (match_dup 0) (pc))
> >> +                               (const_int 128)))
> >> +          (const_int 3)
> >> +          (const_int 7)))])
> >> +
> >
> > Sorry, looking at this again, shouldn't the offset be -125 rather
> > than -126?  The pc in:
> >
> >    (ge (minus (match_dup 0) (pc))
> >        (const_int -126))
> >
> > is the start of the instruction, so we need to add the length
> > of the jump itself to the real minimum range of -128.
> 
> You are right.  Similarly upper bound should be changed from 128 to 129.
> 
> Thanks,
> Ilya
> 
> >
> > Thanks,
> > Richard

Here is a patch to fix it.

Thanks,
Ilya
--
2014-12-08  Ilya Enkovich  <ilya.enkovich@intel.com>

	PR target/64003
	* config/i386/i386.md (*jcc_1_bnd): Fix short jump range.
	(*jcc_2_bnd): Likewise.
	(jump_bnd): Likewise.
diff mbox

Patch

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 9019ed8..eafba04 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -10970,9 +10970,9 @@ 
    (set_attr "modrm" "0")
    (set (attr "length")
 	   (if_then_else (and (ge (minus (match_dup 0) (pc))
-				  (const_int -126))
+				  (const_int -125))
 			      (lt (minus (match_dup 0) (pc))
-				  (const_int 128)))
+				  (const_int 129)))
 	     (const_int 3)
 	     (const_int 7)))])
 
@@ -11006,9 +11006,9 @@ 
    (set_attr "modrm" "0")
    (set (attr "length")
 	   (if_then_else (and (ge (minus (match_dup 0) (pc))
-				  (const_int -126))
+				  (const_int -125))
 			      (lt (minus (match_dup 0) (pc))
-				  (const_int 128)))
+				  (const_int 129)))
 	     (const_int 3)
 	     (const_int 7)))])
 
@@ -11464,9 +11464,9 @@ 
   [(set_attr "type" "ibr")
    (set (attr "length")
 	   (if_then_else (and (ge (minus (match_dup 0) (pc))
-				  (const_int -126))
+				  (const_int -125))
 			      (lt (minus (match_dup 0) (pc))
-				  (const_int 128)))
+				  (const_int 129)))
 	     (const_int 3)
 	     (const_int 6)))
    (set_attr "modrm" "0")])