Commit 6c1a2b3d by Uros Bizjak Committed by Uros Bizjak

re PR target/66412 (ICE on valid code at -O2 and -O3 with -g enabled in…

re PR target/66412 (ICE on valid code at -O2 and -O3 with -g enabled in simplify_subreg, at simplify-rtx.c:5748)

	PR target/66412
	* config/i386/i386.md (various splitters): Use shallow_copy_rtx
	before doing PUT_MODE or PUT_CODE on operands to avoid
	in-place RTX modification.

testsuite/ChangeLog:

	PR target/66412
	* gcc.target/i386/pr66412.c: New test.


Co-Authored-By: Segher Boessenkool <segher@kernel.crashing.org>

From-SVN: r224994
parent cf3e5186
2015-06-26 Uros Bizjak <ubizjak@gmail.com>
Segher Boessenkool <segher@kernel.crashing.org>
PR target/66412
* config/i386/i386.md (various splitters): Use shallow_copy_rtx
before doing PUT_MODE or PUT_CODE on operands to avoid
in-place RTX modification.
2015-06-25 H.J. Lu <hongjiu.lu@intel.com> 2015-06-25 H.J. Lu <hongjiu.lu@intel.com>
* gentarget-def.c (def_target_insn): Cast return of strtol to * gentarget-def.c (def_target_insn): Cast return of strtol to
......
...@@ -10796,6 +10796,7 @@ ...@@ -10796,6 +10796,7 @@
[(set (match_dup 2) (match_dup 1)) [(set (match_dup 2) (match_dup 1))
(set (match_dup 0) (zero_extend:DI (match_dup 2)))] (set (match_dup 0) (zero_extend:DI (match_dup 2)))]
{ {
operands[1] = shallow_copy_rtx (operands[1]);
PUT_MODE (operands[1], QImode); PUT_MODE (operands[1], QImode);
operands[2] = gen_lowpart (QImode, operands[0]); operands[2] = gen_lowpart (QImode, operands[0]);
}) })
...@@ -10813,6 +10814,7 @@ ...@@ -10813,6 +10814,7 @@
(parallel [(set (match_dup 0) (zero_extend:SI (match_dup 2))) (parallel [(set (match_dup 0) (zero_extend:SI (match_dup 2)))
(clobber (reg:CC FLAGS_REG))])] (clobber (reg:CC FLAGS_REG))])]
{ {
operands[1] = shallow_copy_rtx (operands[1]);
PUT_MODE (operands[1], QImode); PUT_MODE (operands[1], QImode);
operands[2] = gen_lowpart (QImode, operands[0]); operands[2] = gen_lowpart (QImode, operands[0]);
}) })
...@@ -10828,6 +10830,7 @@ ...@@ -10828,6 +10830,7 @@
[(set (match_dup 2) (match_dup 1)) [(set (match_dup 2) (match_dup 1))
(set (match_dup 0) (zero_extend:SI (match_dup 2)))] (set (match_dup 0) (zero_extend:SI (match_dup 2)))]
{ {
operands[1] = shallow_copy_rtx (operands[1]);
PUT_MODE (operands[1], QImode); PUT_MODE (operands[1], QImode);
operands[2] = gen_lowpart (QImode, operands[0]); operands[2] = gen_lowpart (QImode, operands[0]);
}) })
...@@ -10865,7 +10868,10 @@ ...@@ -10865,7 +10868,10 @@
(const_int 0)))] (const_int 0)))]
"" ""
[(set (match_dup 0) (match_dup 1))] [(set (match_dup 0) (match_dup 1))]
"PUT_MODE (operands[1], QImode);") {
operands[1] = shallow_copy_rtx (operands[1]);
PUT_MODE (operands[1], QImode);
})
(define_split (define_split
[(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand")) [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand"))
...@@ -10874,7 +10880,10 @@ ...@@ -10874,7 +10880,10 @@
(const_int 0)))] (const_int 0)))]
"" ""
[(set (match_dup 0) (match_dup 1))] [(set (match_dup 0) (match_dup 1))]
"PUT_MODE (operands[1], QImode);") {
operands[1] = shallow_copy_rtx (operands[1]);
PUT_MODE (operands[1], QImode);
})
(define_split (define_split
[(set (match_operand:QI 0 "nonimmediate_operand") [(set (match_operand:QI 0 "nonimmediate_operand")
...@@ -10884,15 +10893,15 @@ ...@@ -10884,15 +10893,15 @@
"" ""
[(set (match_dup 0) (match_dup 1))] [(set (match_dup 0) (match_dup 1))]
{ {
rtx new_op1 = copy_rtx (operands[1]); operands[1] = shallow_copy_rtx (operands[1]);
operands[1] = new_op1; PUT_MODE (operands[1], QImode);
PUT_MODE (new_op1, QImode); PUT_CODE (operands[1],
PUT_CODE (new_op1, ix86_reverse_condition (GET_CODE (new_op1), ix86_reverse_condition (GET_CODE (operands[1]),
GET_MODE (XEXP (new_op1, 0)))); GET_MODE (XEXP (operands[1], 0))));
/* Make sure that (a) the CCmode we have for the flags is strong /* Make sure that (a) the CCmode we have for the flags is strong
enough for the reversed compare or (b) we have a valid FP compare. */ enough for the reversed compare or (b) we have a valid FP compare. */
if (! ix86_comparison_operator (new_op1, VOIDmode)) if (! ix86_comparison_operator (operands[1], VOIDmode))
FAIL; FAIL;
}) })
...@@ -10904,15 +10913,15 @@ ...@@ -10904,15 +10913,15 @@
"" ""
[(set (match_dup 0) (match_dup 1))] [(set (match_dup 0) (match_dup 1))]
{ {
rtx new_op1 = copy_rtx (operands[1]); operands[1] = shallow_copy_rtx (operands[1]);
operands[1] = new_op1; PUT_MODE (operands[1], QImode);
PUT_MODE (new_op1, QImode); PUT_CODE (operands[1],
PUT_CODE (new_op1, ix86_reverse_condition (GET_CODE (new_op1), ix86_reverse_condition (GET_CODE (operands[1]),
GET_MODE (XEXP (new_op1, 0)))); GET_MODE (XEXP (operands[1], 0))));
/* Make sure that (a) the CCmode we have for the flags is strong /* Make sure that (a) the CCmode we have for the flags is strong
enough for the reversed compare or (b) we have a valid FP compare. */ enough for the reversed compare or (b) we have a valid FP compare. */
if (! ix86_comparison_operator (new_op1, VOIDmode)) if (! ix86_comparison_operator (operands[1], VOIDmode))
FAIL; FAIL;
}) })
...@@ -11031,7 +11040,10 @@ ...@@ -11031,7 +11040,10 @@
(if_then_else (match_dup 0) (if_then_else (match_dup 0)
(label_ref (match_dup 1)) (label_ref (match_dup 1))
(pc)))] (pc)))]
"PUT_MODE (operands[0], VOIDmode);") {
operands[0] = shallow_copy_rtx (operands[0]);
PUT_MODE (operands[0], VOIDmode);
})
(define_split (define_split
[(set (pc) [(set (pc)
...@@ -11046,15 +11058,15 @@ ...@@ -11046,15 +11058,15 @@
(label_ref (match_dup 1)) (label_ref (match_dup 1))
(pc)))] (pc)))]
{ {
rtx new_op0 = copy_rtx (operands[0]); operands[0] = shallow_copy_rtx (operands[0]);
operands[0] = new_op0; PUT_MODE (operands[0], VOIDmode);
PUT_MODE (new_op0, VOIDmode); PUT_CODE (operands[0],
PUT_CODE (new_op0, ix86_reverse_condition (GET_CODE (new_op0), ix86_reverse_condition (GET_CODE (operands[0]),
GET_MODE (XEXP (new_op0, 0)))); GET_MODE (XEXP (operands[0], 0))));
/* Make sure that (a) the CCmode we have for the flags is strong /* Make sure that (a) the CCmode we have for the flags is strong
enough for the reversed compare or (b) we have a valid FP compare. */ enough for the reversed compare or (b) we have a valid FP compare. */
if (! ix86_comparison_operator (new_op0, VOIDmode)) if (! ix86_comparison_operator (operands[0], VOIDmode))
FAIL; FAIL;
}) })
...@@ -11091,7 +11103,7 @@ ...@@ -11091,7 +11103,7 @@
(pc)))] (pc)))]
{ {
operands[2] = simplify_gen_subreg (<MODE>mode, operands[2], QImode, 0); operands[2] = simplify_gen_subreg (<MODE>mode, operands[2], QImode, 0);
operands[0] = shallow_copy_rtx (operands[0]);
PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0]))); PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0])));
}) })
...@@ -11124,7 +11136,7 @@ ...@@ -11124,7 +11136,7 @@
(pc)))] (pc)))]
{ {
operands[2] = simplify_gen_subreg (<MODE>mode, operands[2], SImode, 0); operands[2] = simplify_gen_subreg (<MODE>mode, operands[2], SImode, 0);
operands[0] = shallow_copy_rtx (operands[0]);
PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0]))); PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0])));
}) })
...@@ -11160,7 +11172,7 @@ ...@@ -11160,7 +11172,7 @@
(pc)))] (pc)))]
{ {
operands[2] = simplify_gen_subreg (<MODE>mode, operands[2], SImode, 0); operands[2] = simplify_gen_subreg (<MODE>mode, operands[2], SImode, 0);
operands[0] = shallow_copy_rtx (operands[0]);
PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0]))); PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0])));
}) })
...@@ -11192,7 +11204,7 @@ ...@@ -11192,7 +11204,7 @@
(pc)))] (pc)))]
{ {
operands[2] = simplify_gen_subreg (SImode, operands[2], QImode, 0); operands[2] = simplify_gen_subreg (SImode, operands[2], QImode, 0);
operands[0] = shallow_copy_rtx (operands[0]);
PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0]))); PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0])));
}) })
...@@ -11228,7 +11240,10 @@ ...@@ -11228,7 +11240,10 @@
(if_then_else (match_op_dup 0 [(reg:CCC FLAGS_REG) (const_int 0)]) (if_then_else (match_op_dup 0 [(reg:CCC FLAGS_REG) (const_int 0)])
(label_ref (match_dup 4)) (label_ref (match_dup 4))
(pc)))] (pc)))]
"PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0])));") {
operands[0] = shallow_copy_rtx (operands[0]);
PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0])));
})
;; Define combination compare-and-branch fp compare instructions to help ;; Define combination compare-and-branch fp compare instructions to help
;; combine. ;; combine.
...@@ -17298,6 +17313,7 @@ ...@@ -17298,6 +17313,7 @@
operands[1] = gen_lowpart (SImode, operands[1]); operands[1] = gen_lowpart (SImode, operands[1]);
if (GET_CODE (operands[3]) != ASHIFT) if (GET_CODE (operands[3]) != ASHIFT)
operands[2] = gen_lowpart (SImode, operands[2]); operands[2] = gen_lowpart (SImode, operands[2]);
operands[3] = shallow_copy_rtx (operands[3]);
PUT_MODE (operands[3], SImode); PUT_MODE (operands[3], SImode);
}) })
......
2015-06-26 Uros Bizjak <ubizjak@gmail.com>
PR target/66412
* gcc.target/i386/pr66412.c: New test.
2015-06-25 Richard Biener <rguenther@suse.de> 2015-06-25 Richard Biener <rguenther@suse.de>
* gcc.dg/tree-ssa/pr52631.c: Disable forwprop. * gcc.dg/tree-ssa/pr52631.c: Disable forwprop.
......
/* { dg-do compile } */
/* { dg-options "-O2 -g" } */
int a, b, c, d;
void
fn1 ()
{
short e;
unsigned short g;
for (c = 0; c < 1; c++)
d = 0;
g = ((a == 0) ^ d) % 8;
e = g << 1;
b = e && 1;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment