[PATCH] D90162: [llvm][AArch64] Prevent spurious zero extension.

Francesco Petrogalli via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 2 08:01:00 PST 2020


fpetrogalli marked an inline comment as done.
fpetrogalli added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:5748
+    if (NarrowVT != LHS.getOperand(0).getValueType())
+      return false;
+
----------------
efriedma wrote:
> Shouldn't this be a less-than comparison as opposed to exact equality?  For example, suppose the bitmask is equal to one,
(notice that this inline comment now applies to D90605.

@efriedma - I did that and introduced the extra truncate that is needed before the zero extend, with `BitMaskVT` being set accordingly to the mask.

```
EVT BitMaskVT;
if (IsAndZeroExtMask(N0, N1, BitMaskVT))
    return DAG.getNode(ISD::ZERO_EXTEND, SDLoc(N), VT, DAG.getNode(SDLoc(N), BitMaskVTN0.getOperand(0)));
```

This generates a loop in the DAGCOmbine because now the zero extend + truncate combination is rendered to the same AND + BITMASK it is trying to replace.

Do you think it is worth investigating more?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90162/new/

https://reviews.llvm.org/D90162



More information about the llvm-commits mailing list