[llvm] [GISel][CombinerHelper] Combine op(trunc(x), trunc(y)) -> trunc(op(x, y)) (PR #89023)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon May 20 09:55:04 PDT 2024


================
@@ -3083,8 +3083,10 @@ bool CombinerHelper::matchHoistLogicOpWithSameOpcodeHands(
     return false;
   case TargetOpcode::G_ANYEXT:
   case TargetOpcode::G_SEXT:
-  case TargetOpcode::G_ZEXT: {
+  case TargetOpcode::G_ZEXT:
+  case TargetOpcode::G_TRUNC: {
     // Match: logic (ext X), (ext Y) --> ext (logic X, Y)
+    // Match: logic (trunc X), (trunc Y) -> trunc (logic X, Y)
----------------
arsenm wrote:

The logic for the DAG combine treats the extend and truncate cases a bit differently. The truncate case considers whether the extend and truncate are free, and doesn't do this if they are. Arguably this could be handled by the target not adding the combine, but I don't think we have a way to add combines for specific types right now 

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


More information about the llvm-commits mailing list