[llvm] 9e7defc - [X86] Add test case to check computeKnownBitsForPMADDWD doesn't assume add nsw

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 27 06:21:31 PDT 2024


Author: Simon Pilgrim
Date: 2024-06-27T14:21:17+01:00
New Revision: 9e7defccdab8c21d70d8227c356a46db489dec2a

URL: https://github.com/llvm/llvm-project/commit/9e7defccdab8c21d70d8227c356a46db489dec2a
DIFF: https://github.com/llvm/llvm-project/commit/9e7defccdab8c21d70d8227c356a46db489dec2a.diff

LOG: [X86] Add test case to check computeKnownBitsForPMADDWD doesn't assume add nsw

Added: 
    

Modified: 
    llvm/test/CodeGen/X86/combine-pmadd.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/X86/combine-pmadd.ll b/llvm/test/CodeGen/X86/combine-pmadd.ll
index a375ac1db9a1b..403ee72e9dd98 100644
--- a/llvm/test/CodeGen/X86/combine-pmadd.ll
+++ b/llvm/test/CodeGen/X86/combine-pmadd.ll
@@ -98,6 +98,19 @@ define i32 @combine_pmaddwd_constant() {
   ret i32 %2
 }
 
+; ensure we don't assume pmaddwd performs add nsw
+define i32 @combine_pmaddwd_constant_nsw() {
+; CHECK-LABEL: combine_pmaddwd_constant_nsw:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movl $-2147483648, %eax # imm = 0x80000000
+; CHECK-NEXT:    retq
+  %1 = insertelement <8 x i16> undef, i16 32768, i32 0
+  %2 = shufflevector <8 x i16> %1, <8 x i16> undef, <8 x i32> zeroinitializer
+  %3 = call <4 x i32> @llvm.x86.sse2.pmadd.wd(<8 x i16> %2, <8 x i16> %2)
+  %4 = extractelement <4 x i32> %3, i32 0 ; (-32768*-32768)+(-32768*-32768) = 0x80000000
+  ret i32 %4
+}
+
 define <8 x i16> @combine_pmaddubsw_zero(<16 x i8> %a0, <16 x i8> %a1) {
 ; SSE-LABEL: combine_pmaddubsw_zero:
 ; SSE:       # %bb.0:


        


More information about the llvm-commits mailing list