[PATCH] D119075: [DAGCombine][ARM] Custom lower smaller-than-legal MULH/AVG/ABD

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 11 09:26:55 PST 2022


dmgreen added a comment.

In D119075#3301157 <https://reviews.llvm.org/D119075#3301157>, @RKSimon wrote:

> Fair enough - I was mainly thinking in terms of the AVG opcodes, but I can understand that it might cause other issues.

I often find myself fighting against DAG combines more than I would like. I am a fan of more control from the target.



================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:8775-8777
   // Combine to mulh if mulh is legal/custom for the narrow type on the target.
-  if (!TLI.isOperationLegalOrCustom(MulhOpcode, NarrowVT))
+  if (!TLI.isOperationLegal(MulhOpcode, NarrowVT) &&
+      !TLI.isOperationCustom(MulhOpcode, NarrowVT))
----------------
efriedma wrote:
> I think the predicate you actually need here is something like `!TLI.isOperationLegalOrCustom(MulhOpcode, NarrowVT) && (LegalTypes || !TLI.isOperationCustom(MulhOpcode, NarrowVT))`.  i.e. before type legalization, allow custom lowering.  After type legalization, only allow custom lowering if the type is legal.
> 
> Constructing an operator with an illegal type after type legalization is likely to crash the compiler.
Thanks for the suggestion.


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

https://reviews.llvm.org/D119075



More information about the llvm-commits mailing list