<div dir="ltr"><div><div><div>Hello, <br></div><div>i need ability to change type of instruction operand, changed by ComplexPattern in pattern match.<br></div><div><br></div><div>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.<br><br></div><div></div><div>My .td contains:<br><br></div><div>def SITOFPF : Instruction<br>{<br></div>   ...<br></div>   let InOperandList =(ins Rg32:$rs, Rg32:$p);<br></div>   letOutOperandList = (outs R32:$rd);<br>   ...<br><div><div><div><div>}<br><br></div><div>where Rg32 is RegClass to i32 and f32 values.<br><br>def immfpow2 : ComplexPattern<f32, 1, "SelectImmFPow2">;<br><br>bool ...::SelectImmFPow2(SDValue N, SDValue& C)<br>{<br>    auto fpc = cast<ConstantFPSDNode>(N);<br>    auto p = log2(fpc->getConstantFPValue()->getValueAPF().convertToFloat());<br><br>    if (remainderf(p, 1) != 0)<br>        return false;<br><br>    C = CurDAG->getTargetConstant(p, SDLoc(N), MVT::i8);<br><br>    return true;<br>}</div><div><br>def : Pat<(fdiv (f32 (sint_to_fp Rg32:$s)), (f32 immfpow2:$p)), (SITOFPF $s, $p)>;<br><br></div><div>I need to second operand of SITOFPF have type i8. If i changed input operand definition to (ins Rg32:$rs, Operand<i8>:$p),  tablegen says 'Type inference contradiction found, merging 'f32' into 'i8''.<br><br></div><div>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?<br></div><div><br></div><div>Thanks.<br></div></div></div></div></div>