Change operand type in tablegen pattern

Hello,

i need ability to change type of instruction operand, changed by ComplexPattern in pattern match.

i have pattern, which match operation (fdiv (f32 (sint_to_fp Rg32:$s)), (f32 immfpow2:$p)) and replace it with one instruction. In case, if second fdiv operand is power of 2 - this operation convert fixed point value to float point value.

My .td contains:

def SITOFPF : Instruction
{

let InOperandList =(ins Rg32:$rs, Rg32:$p);

letOutOperandList = (outs R32:$rd);

}

where Rg32 is RegClass to i32 and f32 values.

def immfpow2 : ComplexPattern<f32, 1, “SelectImmFPow2”>;

bool …::SelectImmFPow2(SDValue N, SDValue& C)
{
auto fpc = cast(N);
auto p = log2(fpc->getConstantFPValue()->getValueAPF().convertToFloat());

if (remainderf(p, 1) != 0)
return false;

C = CurDAG->getTargetConstant(p, SDLoc(N), MVT::i8);

return true;
}

def : Pat<(fdiv (f32 (sint_to_fp Rg32:$s)), (f32 immfpow2:$p)), (SITOFPF $s, $p)>;

I need to second operand of SITOFPF have type i8. If i changed input operand definition to (ins Rg32:$rs, Operand:$p), tablegen says ‘Type inference contradiction found, merging ‘f32’ into ‘i8’’.

Can i specify, in some way, tablegen consider $p in fragment ‘(SITOFPF $s, $p)’ has type i8, not f32, because it will be so if the ComplexPattern matched?

Thanks.