lib/HLSL/HLMatrixLowerPass.cpp
// Replace matInst with vecInst on matUseInst.
Replace matInst with vecInst on matUseInst.
Replace matInst with vecInst on matUseInst .
void HLMatrixLowerPass::TrivialMatBinOpReplace(CallInst *matInst,
                                              Instruction *vecInst,
                                              CallInst *matUseInst) {
  HLBinaryOpcode opcode = static_cast<HLBinaryOpcode>(GetHLOpcode(matUseInst));
  Instruction *vecUseInst = cast<Instruction>(matToVecMap[matUseInst]);
  if (opcode != HLBinaryOpcode::LAnd && opcode != HLBinaryOpcode::LOr) {
    if (matUseInst->getArgOperand(HLOperandIndex::kBinaryOpSrc0Idx) == matInst)
      vecUseInst->setOperand(0, vecInst);
    if (matUseInst->getArgOperand(HLOperandIndex::kBinaryOpSrc1Idx) == matInst)
      vecUseInst->setOperand(1, vecInst);
  } else {
    if (matUseInst->getArgOperand(HLOperandIndex::kBinaryOpSrc0Idx) ==
        matInst) {
      Instruction *vecCmp = cast<Instruction>(vecUseInst->getOperand(0));
      vecCmp->setOperand(0, vecInst);
    }
    if (matUseInst->getArgOperand(HLOperandIndex::kBinaryOpSrc1Idx) ==
        matInst) {
      Instruction *vecCmp = cast<Instruction>(vecUseInst->getOperand(1));
      vecCmp->setOperand(0, vecInst);
    }
  }
}
void HLMatrixLowerPass :: TrivialMatBinOpReplace ( CallInst * matInst , Instruction * vecInst , CallInst * matUseInst ) { HLBinaryOpcode opcode = static_cast < HLBinaryOpcode > ( GetHLOpcode ( matUseInst ) ) ; Instruction * vecUseInst = cast < Instruction > ( matToVecMap [ matUseInst ] ) ; if ( opcode != HLBinaryOpcode :: LAnd && opcode != HLBinaryOpcode :: LOr ) { if ( matUseInst -> getArgOperand ( HLOperandIndex :: kBinaryOpSrc0Idx ) == matInst ) vecUseInst -> setOperand ( 0 , vecInst ) ; if ( matUseInst -> getArgOperand ( HLOperandIndex :: kBinaryOpSrc1Idx ) == matInst ) vecUseInst -> setOperand ( 1 , vecInst ) ; } else { if ( matUseInst -> getArgOperand ( HLOperandIndex :: kBinaryOpSrc0Idx ) == matInst ) { Instruction * vecCmp = cast < Instruction > ( vecUseInst -> getOperand ( 0 ) ) ; vecCmp -> setOperand ( 0 , vecInst ) ; } if ( matUseInst -> getArgOperand ( HLOperandIndex :: kBinaryOpSrc1Idx ) == matInst ) { Instruction * vecCmp = cast < Instruction > ( vecUseInst -> getOperand ( 1 ) ) ; vecCmp -> setOperand ( 0 , vecInst ) ; } } }
Replace matInst with vecInst on matUseInst.
Replace matInst with vecInst on matUseInst .