Skip to content

Conversation

@AlexMaclean
Copy link
Member

The refactoring of ComputePTXValueVTs in #154476 caused the complier to no longer crash when lowering i256 and i96. This has caused a few tests to unexpectedly pass.

Update these tests and tweak how we emit parameter declarations to correctly lower these types.

@llvmbot
Copy link
Member

llvmbot commented Aug 21, 2025

@llvm/pr-subscribers-backend-nvptx

Author: Alex MacLean (AlexMaclean)

Changes

The refactoring of ComputePTXValueVTs in #154476 caused the complier to no longer crash when lowering i256 and i96. This has caused a few tests to unexpectedly pass.

Update these tests and tweak how we emit parameter declarations to correctly lower these types.


Full diff: https://github.com/llvm/llvm-project/pull/154824.diff

3 Files Affected:

  • (modified) llvm/lib/Target/NVPTX/NVPTXUtilities.h (+3-1)
  • (modified) llvm/test/CodeGen/Generic/add-with-overflow-128.ll (-3)
  • (modified) llvm/test/CodeGen/Generic/icmp-illegal.ll (-4)
diff --git a/llvm/lib/Target/NVPTX/NVPTXUtilities.h b/llvm/lib/Target/NVPTX/NVPTXUtilities.h
index 9421f9f54d0a6..a070789f85e0b 100644
--- a/llvm/lib/Target/NVPTX/NVPTXUtilities.h
+++ b/llvm/lib/Target/NVPTX/NVPTXUtilities.h
@@ -82,6 +82,8 @@ inline unsigned promoteScalarArgumentSize(unsigned size) {
     return 32;
   if (size <= 64)
     return 64;
+  if (size <= 128)
+    return 128;
   return size;
 }
 
@@ -89,7 +91,7 @@ bool shouldEmitPTXNoReturn(const Value *V, const TargetMachine &TM);
 
 inline bool shouldPassAsArray(Type *Ty) {
   return Ty->isAggregateType() || Ty->isVectorTy() ||
-         Ty->getScalarSizeInBits() == 128 || Ty->isHalfTy() || Ty->isBFloatTy();
+         Ty->getScalarSizeInBits() >= 128 || Ty->isHalfTy() || Ty->isBFloatTy();
 }
 
 namespace NVPTX {
diff --git a/llvm/test/CodeGen/Generic/add-with-overflow-128.ll b/llvm/test/CodeGen/Generic/add-with-overflow-128.ll
index 389e6511b6c7c..3db446663e71d 100644
--- a/llvm/test/CodeGen/Generic/add-with-overflow-128.ll
+++ b/llvm/test/CodeGen/Generic/add-with-overflow-128.ll
@@ -1,8 +1,5 @@
 ; RUN: llc < %s
 
-; NVPTX fails to LowerFormalArguments for arg type i96
-; the arg byte size must be one of the {16, 8, 4, 2}
-; XFAIL: target=nvptx{{.*}}
 
 @ok = internal constant [4 x i8] c"%d\0A\00"
 @no = internal constant [4 x i8] c"no\0A\00"
diff --git a/llvm/test/CodeGen/Generic/icmp-illegal.ll b/llvm/test/CodeGen/Generic/icmp-illegal.ll
index 1af42e3443d21..77dd5a59dfd1e 100644
--- a/llvm/test/CodeGen/Generic/icmp-illegal.ll
+++ b/llvm/test/CodeGen/Generic/icmp-illegal.ll
@@ -1,9 +1,5 @@
 ; RUN: llc < %s | FileCheck %s
 
-; NVPTX fails to LowerFormalArguments for arg size > i128
-; the arg byte size must be one of the {16, 8, 4, 2}
-; XFAIL: target=nvptx{{.*}}
-
 ; CHECK-LABEL: test_ult
 define i1 @test_ult(i256 %a) nounwind {
   %1 = icmp ult i256 %a, -6432394258550908438

Copy link
Contributor

@Prince781 Prince781 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AlexMaclean AlexMaclean merged commit 9b24ccc into llvm:main Aug 21, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants