[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
Thu Mar 9 10:23:29 PST 2023
chill updated this revision to Diff 503832.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143892/new/
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,34 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -codegenprepare < %s | FileCheck %s
+; REQUIRES: aarch64-registered-target
+
+; Check that we don't give up if unable to sink the first argument.
+
+target triple = "aarch64-linux"
+
+declare void @f(ptr, ptr) cold
+
+define void @g(i1 %c1, ptr %p, i32 %i) {
+; CHECK-LABEL: @g(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[A0:%.*]] = getelementptr ptr, ptr [[P:%.*]], i32 [[I:%.*]]
+; CHECK-NEXT: br i1 [[C1:%.*]], label [[IF_THEN:%.*]], label [[EXIT:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: [[SUNKADDR:%.*]] = getelementptr i8, ptr [[P]], i64 32
+; CHECK-NEXT: call void @f(ptr [[A0]], ptr [[SUNKADDR]])
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: ret void
+;
+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:
+ 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.503832.patch
Type: text/x-patch
Size: 1785 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230309/f9986794/attachment.bin>
More information about the llvm-commits
mailing list