diff mbox

[i386] : Clenup: use bool, true and false in predicate functions

Message ID AANLkTimFZ5s2u9DWpejLdG__ZF3uZTe2kDs0-jJjaG-E@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak Sept. 9, 2010, 11:07 a.m. UTC
On Thu, Sep 9, 2010 at 9:45 AM, Uros Bizjak <ubizjak@gmail.com> wrote:

>>>  (define_predicate "flags_reg_operand"
>>> @@ -98,16 +98,14 @@
>>>  ;; Return true if op is not xmm0 register.
>>>  (define_predicate "reg_not_xmm0_operand"
>>>     (and (match_operand 0 "register_operand")
>>> -     (match_test "!REG_P (op)
>>> -                  || REGNO (op) != FIRST_SSE_REG")))
>>> +     (match_test "REGNO (op) != FIRST_SSE_REG")))
>>
>> This change broke lots of tests with --enable-checking=yes,rtl.
>> op e.g. in vperm-v4si-2-sse4.c isn't a REG, but SUBREG of REG
>> (and, in theory, register_operand can be true also for SUBREG of MEM
>> before reload).
>> So I think this test should be
>> if (GET_CODE (op)) == SUBREG)
>>  op = SUBREG_REG (op);
>> !REG_P (op) || REGNO (op) != FIRST_SSE_REG
>
>
> Whoops, I didn't intend to commit this (untested!) change!

Fixed by attached patch.

2010-09-09  Uros Bizjak  <ubizjak@gmail.com>

	* config/i386/predicates.md (ext_register_operand): Check that
	SUBREG_REG is really a register before looking for REGNO.
	(reg_not_xmm0_operand): Handle SUBREGs correctly.
	(nonimm_not_xmm0_operand): Call reg_not_xmm0_operand.

Tested on x86_64-pc-linux-gnu {,-m32} with --enable-checking=all,rtl.
Committed to mainline SVN.

Uros.
diff mbox

Patch

Index: config/i386/predicates.md
===================================================================
--- config/i386/predicates.md	(revision 164047)
+++ config/i386/predicates.md	(working copy)
@@ -68,7 +68,8 @@ 
     op = SUBREG_REG (op);
 
   /* Be careful to accept only registers having upper parts.  */
-  return REGNO (op) > LAST_VIRTUAL_REGISTER || REGNO (op) <= BX_REG;
+  return (REG_P (op)
+	  && (REGNO (op) > LAST_VIRTUAL_REGISTER || REGNO (op) <= BX_REG));
 })
 
 ;; Return true if op is the AX register.
@@ -97,13 +98,18 @@ 
 
 ;; Return true if op is not xmm0 register.
 (define_predicate "reg_not_xmm0_operand"
-   (and (match_operand 0 "register_operand")
-	(match_test "REGNO (op) != FIRST_SSE_REG")))
+  (match_operand 0 "register_operand")
+{
+  if (GET_CODE (op) == SUBREG)
+    op = SUBREG_REG (op);
 
+  return !REG_P (op) || REGNO (op) != FIRST_SSE_REG;
+})
+
 ;; As above, but allow nonimmediate operands.
 (define_predicate "nonimm_not_xmm0_operand"
-   (ior (match_operand 0 "memory_operand")
-	(match_operand 0 "reg_not_xmm0_operand")))
+  (ior (match_operand 0 "memory_operand")
+       (match_operand 0 "reg_not_xmm0_operand")))
 
 ;; Return true if VALUE can be stored in a sign extended immediate field.
 (define_predicate "x86_64_immediate_operand"