Hi all, I am trying to add support for hardware loops for a 32bit target. In the target QImode is 32bit. The loop counter used in hardware loop construct is 17bit address registers. This is represented using PQImode. Since mode for the doloop pattern is found out after loop discovery it need not be always PQImode . So what i did was to convert the mode of the counter variable to PQImode then emit the a new pattern with PQImode along with other bells and whistles required by the target loop construct. I am able to generate the assembly files with the proper loop initialization instructions and all. But the issue is that the loop counter is set to 0 in the body of the loop.
In define_expand (in doloop_end and doloop_begin) I am converting to PQImode using the following construct: operands[0] = convert_to_mode (PQImode, operands[0], 0); So the above construct will result in an rtl pattern like: (insn 33 17 34 4 loop.c:52 (set (reg:PQI 50) (truncate:PQI (reg:QI 49))) -1 (nil)) But GCC will extract the loop counter from the define_expand generated doloop pattern, which is in PQImode. (insn 33 17 34 4 loop.c:52 (set (reg:PQI 50) (truncate:PQI (reg:QI 49))) -1 (nil)) (jump_insn 34 33 20 4 loop.c:52 (parallel [ (set (pc) (if_then_else (ne (reg:PQI 50) (const_int 1 [0x1])) (label_ref:PQI 30) (pc))) (set (reg:PQI 50) (plus:PQI (reg:PQI 50) (const_int -1 [0xffffffffffffffff]))) (unspec [ (const_int 0 [0x0]) ] 3) (clobber (scratch:PQI)) ]) 62 {doloop_end_pqi} (expr_list:REG_BR_PROB (const_int 9100 [0x238c]) (nil)) -> 30) This is the counter value that gets used for doloop begin. Hence the original loop counter (reg:QI 49) never gets initialized. Due to this 'if-conversion' pass will modify the statement to: (insn 33 38 34 4 loop.c:52 (set (reg:PQI 50) (const_int 0 [0x0])) 9 {movpqi_op} (nil)) This results in loop counter being set to 0 in the body of the loop. Can someone suggest me solution to get out of this? Regards, Shafi