[PATCH] D143892: [CodeGenPrepare] Don't give up if unable to sink first arg to a cold call

Momchil Velikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 13 02:45:32 PST 2023


chill created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
chill requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

https://reviews.llvm.org/D143892

Files:
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/test/CodeGen/Generic/addr-sink-call-multi-arg.ll


Index: llvm/test/CodeGen/Generic/addr-sink-call-multi-arg.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/Generic/addr-sink-call-multi-arg.ll
@@ -0,0 +1,20 @@
+; RUN: llc --stop-after=codegenprepare < %s | FileCheck %s
+
+declare void @f(ptr, ptr) cold
+
+define void @g(i1 %c1, ptr %p, i32 %i) {
+entry:
+    %a0 = getelementptr i32 *, ptr %p, i32 %i
+    %a1 = getelementptr i32 *, ptr %p, i32 4
+    br i1 %c1, label %if.then, label %exit
+
+if.then:
+; Check that we don't give up on the first argument.
+; CHECK:  %sunkaddr = getelementptr i8, ptr %p, i64 32
+; CHECK:  call void @f(ptr %a0, ptr %sunkaddr)
+    call void @f(ptr %a0, ptr %a1)
+    br label %exit
+
+exit:
+    ret void
+}
Index: llvm/lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -2279,7 +2279,8 @@
       if (!Arg->getType()->isPointerTy())
         continue;
       unsigned AS = Arg->getType()->getPointerAddressSpace();
-      return optimizeMemoryInst(CI, Arg, Arg->getType(), AS);
+      if (optimizeMemoryInst(CI, Arg, Arg->getType(), AS))
+        return true;
     }
 
   IntrinsicInst *II = dyn_cast<IntrinsicInst>(CI);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143892.496889.patch
Type: text/x-patch
Size: 1297 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230213/18d86344/attachment.bin>


More information about the llvm-commits mailing list