[PATCH] D144871: [CodeGen] Always expand division larger than i128

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 1 06:33:59 PST 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGddccc5ba4479: [CodeGen] Always expand division larger than i128 (authored by nikic).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144871

Files:
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/test/CodeGen/Mips/idiv_large.ll
  llvm/test/CodeGen/PowerPC/idiv_large.ll
  llvm/test/CodeGen/RISCV/idiv_large.ll


Index: llvm/test/CodeGen/RISCV/idiv_large.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/RISCV/idiv_large.ll
@@ -0,0 +1,17 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 < %s | FileCheck %s
+; RUN: llc -mtriple=riscv64 < %s | FileCheck %s
+
+define i128 @udiv_i128(i128 %x, i128 %y) nounwind {
+; CHECK-LABEL: udiv_i128:
+; CHECK:    call __udivti3
+  %res = udiv i128 %x, %y
+  ret i128 %res
+}
+
+define i129 @udiv_i129(i129 %x, i129 %y) nounwind {
+; CHECK-LABEL: udiv_i129:
+; CHECK-NOT: call{{.*}}div
+  %res = udiv i129 %x, %y
+  ret i129 %res
+}
Index: llvm/test/CodeGen/PowerPC/idiv_large.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/idiv_large.ll
@@ -0,0 +1,17 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=powerpc-- < %s | FileCheck %s
+; RUN: llc -mtriple=powerpc64-- < %s | FileCheck %s
+
+define i128 @udiv_i128(i128 %x, i128 %y) nounwind {
+; CHECK-LABEL: udiv_i128:
+; CHECK:    bl __udivti3
+  %res = udiv i128 %x, %y
+  ret i128 %res
+}
+
+define i129 @udiv_i129(i129 %x, i129 %y) nounwind {
+; CHECK-LABEL: udiv_i129:
+; CHECK-NOT: bl __
+  %res = udiv i129 %x, %y
+  ret i129 %res
+}
Index: llvm/test/CodeGen/Mips/idiv_large.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/Mips/idiv_large.ll
@@ -0,0 +1,17 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=mips-- < %s | FileCheck %s
+; RUN: llc -mtriple=mips64-- < %s | FileCheck %s
+
+define i128 @udiv_i128(i128 %x, i128 %y) nounwind {
+; CHECK-LABEL: udiv_i128:
+; CHECK:    jal __udivti3
+  %res = udiv i128 %x, %y
+  ret i128 %res
+}
+
+define i129 @udiv_i129(i129 %x, i129 %y) nounwind {
+; CHECK-LABEL: udiv_i129:
+; CHECK-NOT: jal
+  %res = udiv i129 %x, %y
+  ret i129 %res
+}
Index: llvm/lib/CodeGen/TargetLoweringBase.cpp
===================================================================
--- llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -724,7 +724,9 @@
   // with the Target-specific changes necessary.
   MaxAtomicSizeInBitsSupported = 1024;
 
-  MaxDivRemBitWidthSupported = llvm::IntegerType::MAX_INT_BITS;
+  // Assume that even with libcalls, no target supports wider than 128 bit
+  // division.
+  MaxDivRemBitWidthSupported = 128;
 
   MaxLargeFPConvertBitWidthSupported = llvm::IntegerType::MAX_INT_BITS;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144871.501492.patch
Type: text/x-patch
Size: 2604 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230301/8d698814/attachment.bin>


More information about the llvm-commits mailing list