[PATCH] D126900: [SystemZ] Fix check for zero size when lowering memcmp.

Kai Nacke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 8 11:52:56 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd897a14c2ef7: [SystemZ] Fix check for zero size when lowering memcmp. (authored by Kai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126900

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/test/CodeGen/SystemZ/memcmp-03.ll


Index: llvm/test/CodeGen/SystemZ/memcmp-03.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/SystemZ/memcmp-03.ll
@@ -0,0 +1,20 @@
+; Test memcmp with 0 size.
+
+; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
+; REQUIRES: asserts
+
+declare i32 @memcmp(i8* nocapture, i8* nocapture, i64)
+
+define hidden void @fun() {
+; CHECK-LABEL: fun
+entry:
+  %len = extractvalue [2 x i64] zeroinitializer, 1
+  br i1 undef, label %end, label %call
+
+call:
+  %res = tail call signext i32 @memcmp(i8* noundef undef, i8* noundef undef, i64 noundef %len)
+  unreachable
+
+end:
+  unreachable
+}
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -7902,7 +7902,7 @@
 bool SelectionDAGBuilder::visitMemCmpBCmpCall(const CallInst &I) {
   const Value *LHS = I.getArgOperand(0), *RHS = I.getArgOperand(1);
   const Value *Size = I.getArgOperand(2);
-  const ConstantInt *CSize = dyn_cast<ConstantInt>(Size);
+  const ConstantSDNode *CSize = dyn_cast<ConstantSDNode>(getValue(Size));
   if (CSize && CSize->getZExtValue() == 0) {
     EVT CallVT = DAG.getTargetLoweringInfo().getValueType(DAG.getDataLayout(),
                                                           I.getType(), true);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126900.435279.patch
Type: text/x-patch
Size: 1437 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220608/2d27d26c/attachment-0001.bin>


More information about the llvm-commits mailing list