[PATCH] D48846: [ARM] Fix PR37382: Don't optimize mul.with.overflow on thumbv6m.

Vadzim Dambrouski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 2 13:51:57 PDT 2018


pftbest updated this revision to Diff 153782.
pftbest added a comment.

Explicit check for __aeabi_lmul


Repository:
  rL LLVM

https://reviews.llvm.org/D48846

Files:
  lib/Target/ARM/ARMISelLowering.cpp
  test/CodeGen/ARM/overflow-intrinsic-optimizations.ll


Index: test/CodeGen/ARM/overflow-intrinsic-optimizations.ll
===================================================================
--- test/CodeGen/ARM/overflow-intrinsic-optimizations.ll
+++ test/CodeGen/ARM/overflow-intrinsic-optimizations.ll
@@ -1,4 +1,5 @@
 ; RUN: llc < %s -mtriple=arm-eabi -mcpu=generic | FileCheck %s
+; RUN: llc < %s -mtriple=thumbv6m-eabi | FileCheck %s -check-prefix=CHECK-V6M-THUMB
 
 define i32 @sadd(i32 %a, i32 %b) local_unnamed_addr #0 {
 ; CHECK-LABEL: sadd:
@@ -81,6 +82,8 @@
 ; CHECK: smull r0, r[[RHI:[0-9]+]], {{r[0-9]+}}, {{r[0-9]+}}
 ; CHECK-NEXT: cmp r[[RHI]], r0, asr #31
 ; CHECK-NEXT: moveq pc, lr
+; CHECK-V6M-THUMB-LABEL: smul:
+; CHECK-V6M-THUMB: bl __aeabi_lmul
 entry:
   %0 = tail call { i32, i1 } @llvm.smul.with.overflow.i32(i32 %a, i32 %b)
   %1 = extractvalue { i32, i1 } %0, 1
@@ -100,6 +103,8 @@
 ; CHECK: umull r0, r[[RHI:[0-9]+]], {{r[0-9]+}}, {{r[0-9]+}}
 ; CHECK-NEXT: cmp r[[RHI]], #0
 ; CHECK-NEXT: moveq pc, lr
+; CHECK-V6M-THUMB-LABEL: umul:
+; CHECK-V6M-THUMB: bl __aeabi_lmul
 entry:
   %0 = tail call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %a, i32 %b)
   %1 = extractvalue { i32, i1 } %0, 1
Index: lib/Target/ARM/ARMISelLowering.cpp
===================================================================
--- lib/Target/ARM/ARMISelLowering.cpp
+++ lib/Target/ARM/ARMISelLowering.cpp
@@ -4681,9 +4681,11 @@
   // Optimize {s|u}{add|sub|mul}.with.overflow feeding into a branch
   // instruction.
   unsigned Opc = Cond.getOpcode();
+  bool OptimizeMul = (Opc == ISD::SMULO || Opc == ISD::UMULO) &&
+                      !Subtarget->isThumb1Only();
   if (Cond.getResNo() == 1 &&
       (Opc == ISD::SADDO || Opc == ISD::UADDO || Opc == ISD::SSUBO ||
-       Opc == ISD::USUBO || Opc == ISD::SMULO || Opc == ISD::UMULO)) {
+       Opc == ISD::USUBO || OptimizeMul)) {
     // Only lower legal XALUO ops.
     if (!DAG.getTargetLoweringInfo().isTypeLegal(Cond->getValueType(0)))
       return SDValue();
@@ -4730,9 +4732,11 @@
   // Optimize {s|u}{add|sub|mul}.with.overflow feeding into a branch
   // instruction.
   unsigned Opc = LHS.getOpcode();
+  bool OptimizeMul = (Opc == ISD::SMULO || Opc == ISD::UMULO) &&
+                      !Subtarget->isThumb1Only();
   if (LHS.getResNo() == 1 && (isOneConstant(RHS) || isNullConstant(RHS)) &&
       (Opc == ISD::SADDO || Opc == ISD::UADDO || Opc == ISD::SSUBO ||
-       Opc == ISD::USUBO || Opc == ISD::SMULO || Opc == ISD::UMULO) &&
+       Opc == ISD::USUBO || OptimizeMul) &&
       (CC == ISD::SETEQ || CC == ISD::SETNE)) {
     // Only lower legal XALUO ops.
     if (!DAG.getTargetLoweringInfo().isTypeLegal(LHS->getValueType(0)))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48846.153782.patch
Type: text/x-patch
Size: 2654 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180702/c2210127/attachment.bin>


More information about the llvm-commits mailing list