On 01/18/2017 12:31 PM, Steve Silva wrote:
Hi All,


I just wanted to thank you for your help; I was able to fix the problem with 
the following RTL

(define_expand "addhi3"
[(set (match_operand:HI 0 "nonimmediate_operand")
(plus:HI (match_operand:HI 1 "nonimmediate_operand")
(match_operand:HI 2 "general_operand")))]
""
{
if((GET_CODE(operands[2]) == CONST_INT) &&
((INTVAL(operands[2]) > 4095) || (INTVAL(operands[2]) < -2048)))
{
emit_insn(gen_addhi3_mem_or_reg(operands[0], operands[1],
force_reg(HImode, operands[2])));
DONE;
}
})

;;*****************************************************************************
;;**  This pattern is for any register or memory target.  This pattern cannot**
;;**  accept immediate values over 12 bits hence the expand above.           **
;;*****************************************************************************
(define_insn "addhi3_mem_or_reg"
[(set (match_operand:HI 0 "nonimmediate_operand" "=a,m")
(plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
(match_operand:HI 2 "general_operand" "aim,aim")))]

Given the way your expander's working, I think you'll come to grief with this insn, once you turn the optimizer on.

That insn will allow any immediate for op-2, and that;s what the optimizer will pay attention to. You probably want your own predicates to exactly match what things an instruction can take.

nathan

--
Nathan Sidwell

Reply via email to