Solution -------- The statement var = const * var is converted by GIMPLE to the form var = var * const. Hence only for one format (var = var * const) rtl instruction has to be defined. (define_expand "mulsi3" [(set (match_operand:SI 0 "register_operand" "") (mult:SI (match_operand:SI 1 "register_operand" "") (match_operand:SI 2 "immediate_operand" "")) )] "" { if(GET_CODE(operands[2])==CONST_INT) // if operand2 is integer constant { int p = INTVAL(operands[2]); // get the value of constant if(p<0) // if the constant is -ve then inform the caller that pattern did not match { fprintf (stderr,"Cannot compile with negative constants\n"); exit (1); } emit_insn(gen_movsi(operands[0],gen_rtx_REG(SImode,0))); int i; for(i=0;i