[llvm] [DAGCombine] Add DAG optimisation for BF16_TO_FP (PR #69426)

Shao-Ce SUN via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 18 20:11:38 PDT 2023


================
@@ -26219,6 +26223,21 @@ SDValue DAGCombiner::visitFP_TO_BF16(SDNode *N) {
   return SDValue();
 }
 
+SDValue DAGCombiner::visitBF16_TO_FP(SDNode *N) {
----------------
sunshaoce wrote:

I tried `SimplifyDemandedBits`, but it didn't work, maybe there's something wrong with my code.

```
SDValue DAGCombiner::visitFP16_TO_FP(SDNode *N) {
  SDValue N0 = N->getOperand(0);
  APInt DemandedBits = APInt::getAllOnes(N0.getScalarValueSizeInBits());
  if (SimplifyDemandedBits(N0, DemandedBits)) {
    if (N->getOpcode() != ISD::DELETED_NODE)
      AddToWorklist(N);
    return SDValue(N, 0);
  }

  return SDValue();
}
```

https://github.com/llvm/llvm-project/pull/69426


More information about the llvm-commits mailing list