From 5e7821eb98292742a6aa4e1495ad1ccf9832d749 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Thu, 22 Jan 2015 14:24:28 -0700 Subject: [PATCH] re PR target/52076 (bloated code for setting single bits in bitfields on m68k) PR target/52076 * config/m68k/m68k.md (xorsi3_internal): Twiddle constraints to improve code density for small immediate to memory case. (insv): Better handle bitfield assignments when the field is being set to all ones. * config/m68k/predicates.md (reg_or_pow2_m1_operand): New operand predicate. PR target/52076 * gcc.target/m68k/pr52076-1.c: New test. * gcc.target/m68k/pr52076-2.c: New test. From-SVN: r220015 --- gcc/ChangeLog | 10 ++++++++ gcc/config/m68k/.m68k.md.swp | Bin 0 -> 16384 bytes gcc/config/m68k/m68k.md | 21 +++++++++++++---- gcc/config/m68k/predicates.md | 13 +++++++++++ gcc/testsuite/ChangeLog | 6 +++++ gcc/testsuite/gcc.target/m68k/pr52076-1.c | 20 ++++++++++++++++ gcc/testsuite/gcc.target/m68k/pr52076-2.c | 27 ++++++++++++++++++++++ 7 files changed, 92 insertions(+), 5 deletions(-) create mode 100755 gcc/config/m68k/.m68k.md.swp create mode 100644 gcc/testsuite/gcc.target/m68k/pr52076-1.c create mode 100644 gcc/testsuite/gcc.target/m68k/pr52076-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c1669330aab..ae5e9a5c332 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2015-01-22 Jeff Law + + PR target/52076 + * config/m68k/m68k.md (xorsi3_internal): Twiddle constraints to + improve code density for small immediate to memory case. + (insv): Better handle bitfield assignments when the field is + being set to all ones. + * config/m68k/predicates.md (reg_or_pow2_m1_operand): New + operand predicate. + 2015-01-22 Rainer Orth Jakub Jelinek diff --git a/gcc/config/m68k/.m68k.md.swp b/gcc/config/m68k/.m68k.md.swp new file mode 100755 index 0000000000000000000000000000000000000000..36d768170c054a1662c5a1a953ec77e948e157bc GIT binary patch literal 16384 zcmeHOYmgjO6&?iCU=Rfb6sWq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7U6i!%in5r0$ zil;Wb2`z=AtdIB!6w{JRU@=je898HkvNF7(JYKGBr93!Vu1uC@XT|8$j2ITv!!sE6 zbK}D^VtQ_7dTO?Wn)BR41=6BvbGdTH)LcajPi_^Phi7KsZ|k5GfL2WU0){e01}$n$ zGzjZCtR@0#lB_bN5+9orOm!yQ;R#+X*AZONSi@8#M_H7MG0x?%KnOGiR{9u&+?`T? zDr?k(=(F+Sag-M1a-;&G|rR3xIh8x_K6#co1&X{Aoq6g&9F zDoJhz5LhxP2{D4;Kz^wQqJ5-8^n7SwT~}|hXU#zs=oDpJjk43k{^?gn3AK;*JSfxa z6cY|64#%Q(KoO(s%xK``X#al;_TwMHex3IJ@%w>iu-Cs6xC6Ki_ztiDoC%x;tN>oX zzW-+6dfCIdCyx06H)WP`RfA*_A1fDUd0UDUd0UDUd0U zDUd0UDUd1fU#>uVe7=$Qo7j&vw0uWy-#yic?&O3xs~zuus!9;x6;u=IN6@&T0>BdIyCc^0*TxV}U4kY!h>nv(u%KYI#G)wp@G5A(wO`_qn_~-**Iv zmjj-zG~{Ml?mk;iiD(l_$Dwk2kA1qYVy7F@aXh`|lZP^Via}=^c)O!39+gsVaW9Y0 z{BWKQ{pRUV3P*r+l0*Cc`0S?jWD182bS_lL9Yl_rjbn{i5>{l{GJ%U5Un!S5(ERA0 zXpc_!_~dH+Y#E2~`S?J#%C{l22bZ~Jtn2y>5hHZV_|< literal 0 HcmV?d00001 diff --git a/gcc/config/m68k/m68k.md b/gcc/config/m68k/m68k.md index d34ad1dce88..6bb296e9e0d 100644 --- a/gcc/config/m68k/m68k.md +++ b/gcc/config/m68k/m68k.md @@ -3838,9 +3838,9 @@ "") (define_insn "xorsi3_internal" - [(set (match_operand:SI 0 "nonimmediate_operand" "=do,m") - (xor:SI (match_operand:SI 1 "general_operand" "%0,0") - (match_operand:SI 2 "general_operand" "di,dKT")))] + [(set (match_operand:SI 0 "nonimmediate_operand" "=d,o,m") + (xor:SI (match_operand:SI 1 "general_operand" "%0, 0,0") + (match_operand:SI 2 "general_operand" "di,dK,dKT")))] "!TARGET_COLDFIRE" { @@ -5583,9 +5583,20 @@ [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "") (match_operand:SI 1 "const_int_operand" "") (match_operand:SI 2 "const_int_operand" "")) - (match_operand:SI 3 "register_operand" ""))] + (match_operand:SI 3 "reg_or_pow2_m1_operand" ""))] "TARGET_68020 && TARGET_BITFIELD" - "") + " +{ + /* Special case initializing a field to all ones. */ + if (GET_CODE (operands[3]) == CONST_INT) + { + if (exact_log2 (INTVAL (operands[3]) + 1) != INTVAL (operands[1])) + operands[3] = force_reg (SImode, operands[3]); + else + operands[3] = constm1_rtx; + + } +}") (define_insn "*insv_bfins_mem" [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o") diff --git a/gcc/config/m68k/predicates.md b/gcc/config/m68k/predicates.md index a7b5c42e2fd..c652f109128 100644 --- a/gcc/config/m68k/predicates.md +++ b/gcc/config/m68k/predicates.md @@ -244,3 +244,16 @@ || reload_in_progress || reload_completed)); }) + +;; Used to detect when an operand is either a register +;; or a constant that is all ones in its lower bits. +;; Used by insv pattern to help detect when we're initializing +;; a bitfield to all ones. + +(define_predicate "reg_or_pow2_m1_operand" + (match_code "reg,const_int") +{ + return (REG_P (op) + || (GET_CODE (op) == CONST_INT + && exact_log2 (INTVAL (op) + 1) >= 0)); +}) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8bebdac3cf8..1fc0241b994 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-01-22 Jeff Law + + PR target/52076 + * gcc.target/m68k/pr52076-1.c: New test. + * gcc.target/m68k/pr52076-2.c: New test. + 2015-01-22 Richard Biener PR middle-end/64728 diff --git a/gcc/testsuite/gcc.target/m68k/pr52076-1.c b/gcc/testsuite/gcc.target/m68k/pr52076-1.c new file mode 100644 index 00000000000..86df0dcae43 --- /dev/null +++ b/gcc/testsuite/gcc.target/m68k/pr52076-1.c @@ -0,0 +1,20 @@ +/* { dg-do assemble } /* +/* { dg-options "-Os -fomit-frame-pointer -m68040" } */ +/* { dg-final { object-size text <= 72 } } */ + +struct kobject { + unsigned int b7:1; + unsigned int :6; + unsigned int b0:1; + unsigned char x; + unsigned int f; +}; + +void ior(struct kobject *kobj) { kobj->f |= 4; } +void ior_m(struct kobject *kobj) { kobj->f |= -4; } + +void xor(struct kobject *kobj) { kobj->f ^= 4; } +void xor_m(struct kobject *kobj) { kobj->f ^= -4; } + +void and(struct kobject *kobj) { kobj->f &= 4; } +void and_m(struct kobject *kobj) { kobj->f &= -4; } diff --git a/gcc/testsuite/gcc.target/m68k/pr52076-2.c b/gcc/testsuite/gcc.target/m68k/pr52076-2.c new file mode 100644 index 00000000000..30c6991839c --- /dev/null +++ b/gcc/testsuite/gcc.target/m68k/pr52076-2.c @@ -0,0 +1,27 @@ +/* { dg-do assemble } /* +/* { dg-options "-Os -fomit-frame-pointer -m68040" } */ +/* { dg-final { object-size text <= 30 } } */ + +struct kobject { + unsigned int b7:1; + unsigned int b56:2; + unsigned int b1234:4; + unsigned int b0:1; + unsigned char x; + unsigned int f; +}; + +void b7(struct kobject *kobj) +{ + kobj->b7 = 1; +} + +void b56(struct kobject *kobj) +{ + kobj->b56 = 3; +} + +void b1234(struct kobject *kobj) +{ + kobj->b1234 = 15; +} -- 2.30.2