This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
3.2 bug or something really odd.
- From: Dmitry <diwil at eis dot ru>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 22 Jan 2003 10:38:08 +0300
- Subject: 3.2 bug or something really odd.
- Organization: EIS
- Reply-to: diwil at eis dot ru
Hi Fellows,
I faced with the following gcc3.2 tricky behaviour.
I define following patterns:
(define_expand "extzv"
[(set (match_operand:QI 0 "nonimmediate_operand_msp430" "")
(zero_extract:QI (match_operand:QI 1 "nonimmediate_operand_msp430" "")
(match_operand 2 "const_int_operand" "")
(match_operand 3 "const_int_operand" "")))]
""
"{
if(INTVAL(operands[2]) != 1 || INTVAL(operands[3]) <= 0)
FAIL;
operands[3] = GEN_INT(1<<INTVAL(operands[3]));
}")
(define_insn "*extzv"
[(set (match_operand:QI 0 "nonimmediate_operand_msp430" "=r,r,r,r,m,m,m,m")
(zero_extract:QI (match_operand:QI 1 "nonimmediate_operand_msp430"
"r,m,r,m,r,m,r,m")
(match_operand 2 "const_int_operand"
"i,i,i,i,i,i,i,i")
(match_operand 3 "const_int_operand"
"P,P,i,i,P,P,i,i")))]
""
"bit.b\\t%3, %1
\\tclr.b\\t%0
\\tadc.b\\t%0"
[(set_attr "length" "3,4,4,5,5,6,6,7")
(set_attr "cc" "clobber")])
And for the code given:
unsigned char doit(unsigned char x) {return (x >> 1) & 7; }
The compiler generates:
; (insn 14 13 15 (set (reg:QI 15 r15 [26])
; (zero_extract:QI (reg/v:QI 15 r15 [23])
; (const_int 3 [0x3])
; (const_int 1 [0x1]))) 156 {*extzv} (nil)
; (nil))
bit.b #llo(1), r15 ; 14 *extzv/1 [length = 3]
clr.b r15
adc.b r15
; (insn 15 14 19 (set (reg:HI 15 r15 [24])
; (zero_extend:HI (reg:QI 15 r15 [26]))) 149 {zero_extendqihi2}
(insn_list 14 (nil))
; (nil))
and.b #-1,r15 ; 15 zero_extendqihi2/1 [length = 1]
ret
As follows from the expander defenition, if the operands[2] not equal to 1 the
extzv parrern must be ignored.
However, as follows from the rtl dump, gcc ignores 'FAIL' directive and issues
tricky code.
The extzv pattern first appears after 'combine' pass.
GCC-current lacks this 'feature'.
Should I put an another condition in insn pattern '*extzv' like
'operands[2] == 1' ?
Or this is just something I cannot spot?
Thanks,
Dmitry.