[PATCH] D142791: [GlobalISel] Don't combine instructions with unknown type in hoist_logic_op_with_same_opcode_hands.

Vladislav Dzhidzhoev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 27 16:40:43 PST 2023


dzhidzhoev created this revision.
dzhidzhoev added reviewers: paquette, arsenm, dsanders, aemerson.
Herald added a subscriber: hiraditya.
Herald added a project: All.
dzhidzhoev requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

This fixes failure for some LLVM IR.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142791

Files:
  llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
  llvm/test/CodeGen/AArch64/GlobalISel/postlegalizercombiner-hoist-same-hands.mir


Index: llvm/test/CodeGen/AArch64/GlobalISel/postlegalizercombiner-hoist-same-hands.mir
===================================================================
--- llvm/test/CodeGen/AArch64/GlobalISel/postlegalizercombiner-hoist-same-hands.mir
+++ llvm/test/CodeGen/AArch64/GlobalISel/postlegalizercombiner-hoist-same-hands.mir
@@ -58,3 +58,20 @@
     %logic_op:_(s64) = G_OR %hand1, %hand2
     $x0 = COPY %logic_op(s64)
     RET_ReallyLR implicit $x0
+
+...
+---
+name:            dont_combine_physreg
+tracksRegLiveness: true
+legalized: true
+body:             |
+  bb.0:
+    liveins: $w0, $w1
+    ; Post-legalization, we must not crash here.
+    ;
+    ; CHECK-LABEL: name: dont_combine_physreg
+    %x:_(s32) = COPY $w0
+    %y:_(s32) = COPY $w1
+    %logic_op:_(s32) = G_OR %x, %y
+    $w0 = COPY %logic_op(s32)
+    RET_ReallyLR implicit $w0
Index: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -2750,7 +2750,7 @@
   Register Y = RightHandInst->getOperand(1).getReg();
   LLT XTy = MRI.getType(X);
   LLT YTy = MRI.getType(Y);
-  if (XTy != YTy)
+  if (!XTy.isValid() || !YTy.isValid() || XTy != YTy)
     return false;
   if (!isLegalOrBeforeLegalizer({LogicOpcode, {XTy, YTy}}))
     return false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142791.492948.patch
Type: text/x-patch
Size: 1380 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230128/fa59bc8b/attachment.bin>


More information about the llvm-commits mailing list