[PATCH] D64213: [SystemZ] Fix addcarry of usubo (PR42512)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 5 13:37:18 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL365242: [SystemZ] Fix addcarry of usubo (PR42512) (authored by nikic, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D64213?vs=208218&id=208229#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64213

Files:
  llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp
  llvm/trunk/test/CodeGen/SystemZ/pr42512.ll


Index: llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp
===================================================================
--- llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -3449,11 +3449,17 @@
   switch (Op.getOpcode()) {
   default: llvm_unreachable("Unknown instruction!");
   case ISD::ADDCARRY:
+    if (Carry.getOpcode() != ISD::UADDO && Carry.getOpcode() != ISD::ADDCARRY)
+      return SDValue();
+
     BaseOp = SystemZISD::ADDCARRY;
     CCValid = SystemZ::CCMASK_LOGICAL;
     CCMask = SystemZ::CCMASK_LOGICAL_CARRY;
     break;
   case ISD::SUBCARRY:
+    if (Carry.getOpcode() != ISD::USUBO && Carry.getOpcode() != ISD::SUBCARRY)
+      return SDValue();
+
     BaseOp = SystemZISD::SUBCARRY;
     CCValid = SystemZ::CCMASK_LOGICAL;
     CCMask = SystemZ::CCMASK_LOGICAL_BORROW;
Index: llvm/trunk/test/CodeGen/SystemZ/pr42512.ll
===================================================================
--- llvm/trunk/test/CodeGen/SystemZ/pr42512.ll
+++ llvm/trunk/test/CodeGen/SystemZ/pr42512.ll
@@ -0,0 +1,23 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
+
+define i8 @test(i8 %x) {
+; CHECK-LABEL: test:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    slgfi %r0, 1
+; CHECK-NEXT:    ipm %r0
+; CHECK-NEXT:    afi %r0, -536870912
+; CHECK-NEXT:    srl %r0, 31
+; CHECK-NEXT:    ar %r2, %r0
+; CHECK-NEXT:    br %r14
+  %usubo = tail call { i64, i1 } @llvm.usub.with.overflow.i64(i64 undef, i64 1)
+  %ov = extractvalue { i64, i1 } %usubo, 1
+  %ovext = zext i1 %ov to i8
+  %ret = add i8 %x, %ovext
+  ret i8 %ret
+}
+
+; Function Attrs: nounwind readnone speculatable
+declare { i64, i1 } @llvm.usub.with.overflow.i64(i64, i64) #0
+
+attributes #0 = { nounwind readnone speculatable }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64213.208229.patch
Type: text/x-patch
Size: 1858 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190705/8bea74e6/attachment.bin>


More information about the llvm-commits mailing list