This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
i386 fix
- To: gcc-patches at gcc dot gnu dot org, rth at cygnus dot com, patches at x86-64 dot org
- Subject: i386 fix
- From: Jan Hubicka <jh at suse dot cz>
- Date: Wed, 27 Jun 2001 15:48:44 +0200
Hi
In 64bit mode, the cmpdi expander can be called with noncanonical operands,
as the second operand is forced to be register (constaint is out of range)
and first still contain constant.
Backend accepts this and keeps it noncanonical crashing later.
Wed Jun 27 15:45:16 CEST 2001 Jan Hubicka <jh@suse.cz>
* i386.md (cmp?i): Simplify; refuse immediate operand
in alternative 0
* i386.c (cmpsi_operand): Refuse constants.
Index: config/i386/i386.md
===================================================================
RCS file: /home/cvs/Repository/gcc/gcc/config/i386/i386.md,v
retrieving revision 1.74
diff -c -3 -p -r1.74 i386.md
*** config/i386/i386.md 2001/05/31 14:14:03 1.74
--- config/i386/i386.md 2001/06/27 12:40:54
***************
*** 1005,1017 ****
(define_expand "cmpdi"
[(set (reg:CC 17)
! (compare:CC (match_operand:DI 0 "x86_64_general_operand" "")
(match_operand:DI 1 "x86_64_general_operand" "")))]
""
"
{
! if ((GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
! || (CONSTANT_P (operands[0]) && CONSTANT_P (operands[1])))
operands[0] = force_reg (DImode, operands[0]);
ix86_compare_op0 = operands[0];
ix86_compare_op1 = operands[1];
--- 1005,1016 ----
(define_expand "cmpdi"
[(set (reg:CC 17)
! (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
(match_operand:DI 1 "x86_64_general_operand" "")))]
""
"
{
! if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
operands[0] = force_reg (DImode, operands[0]);
ix86_compare_op0 = operands[0];
ix86_compare_op1 = operands[1];
***************
*** 1025,1032 ****
""
"
{
! if ((GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
! || (CONSTANT_P (operands[0]) && CONSTANT_P (operands[1])))
operands[0] = force_reg (SImode, operands[0]);
ix86_compare_op0 = operands[0];
ix86_compare_op1 = operands[1];
--- 1024,1030 ----
""
"
{
! if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
operands[0] = force_reg (SImode, operands[0]);
ix86_compare_op0 = operands[0];
ix86_compare_op1 = operands[1];
***************
*** 1035,1047 ****
(define_expand "cmphi"
[(set (reg:CC 17)
! (compare:CC (match_operand:HI 0 "general_operand" "")
(match_operand:HI 1 "general_operand" "")))]
""
"
{
! if ((GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
! || (CONSTANT_P (operands[0]) && CONSTANT_P (operands[1])))
operands[0] = force_reg (HImode, operands[0]);
ix86_compare_op0 = operands[0];
ix86_compare_op1 = operands[1];
--- 1033,1044 ----
(define_expand "cmphi"
[(set (reg:CC 17)
! (compare:CC (match_operand:HI 0 "nonimmediate_operand" "")
(match_operand:HI 1 "general_operand" "")))]
""
"
{
! if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
operands[0] = force_reg (HImode, operands[0]);
ix86_compare_op0 = operands[0];
ix86_compare_op1 = operands[1];
***************
*** 1050,1062 ****
(define_expand "cmpqi"
[(set (reg:CC 17)
! (compare:CC (match_operand:QI 0 "general_operand" "")
(match_operand:QI 1 "general_operand" "")))]
"TARGET_QIMODE_MATH"
"
{
! if ((GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
! || (CONSTANT_P (operands[0]) && CONSTANT_P (operands[1])))
operands[0] = force_reg (QImode, operands[0]);
ix86_compare_op0 = operands[0];
ix86_compare_op1 = operands[1];
--- 1047,1058 ----
(define_expand "cmpqi"
[(set (reg:CC 17)
! (compare:CC (match_operand:QI 0 "nonimmediate_operand" "")
(match_operand:QI 1 "general_operand" "")))]
"TARGET_QIMODE_MATH"
"
{
! if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
operands[0] = force_reg (QImode, operands[0]);
ix86_compare_op0 = operands[0];
ix86_compare_op1 = operands[1];
Index: config/i386/i386.c
===================================================================
RCS file: /home/cvs/Repository/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.76
diff -c -3 -p -r1.76 i386.c
*** config/i386/i386.c 2001/05/26 00:00:57 1.76
--- config/i386/i386.c 2001/06/27 12:46:50
*************** cmpsi_operand (op, mode)
*** 2773,2779 ****
rtx op;
enum machine_mode mode;
{
! if (general_operand (op, mode))
return 1;
if (GET_CODE (op) == AND
--- 2773,2779 ----
rtx op;
enum machine_mode mode;
{
! if (nonimmediate_operand (op, mode))
return 1;
if (GET_CODE (op) == AND