Skip to content

Commit 0026251

Browse files
committed
[X86] Add PR39464 addcarry/subborrow test cases
Additional coverage for D70079
1 parent 3130a88 commit 0026251

File tree

2 files changed

+121
-1
lines changed

2 files changed

+121
-1
lines changed

llvm/test/CodeGen/X86/addcarry.ll

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
22
; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s
33

4+
declare { i8, i64 } @llvm.x86.addcarry.64(i8, i64, i64)
45
declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i64) #1
56

67
define i128 @add128(i128 %a, i128 %b) nounwind {
@@ -829,3 +830,62 @@ define i32 @add_U320_uaddo(%struct.U320* nocapture dereferenceable(40) %0, i64 %
829830
%52 = zext i1 %51 to i32
830831
ret i32 %52
831832
}
833+
834+
%struct.U192 = type { [3 x i64] }
835+
836+
define void @PR39464(%struct.U192* noalias nocapture sret %0, %struct.U192* nocapture readonly dereferenceable(24) %1, %struct.U192* nocapture readonly dereferenceable(24) %2) {
837+
; CHECK-LABEL: PR39464:
838+
; CHECK: # %bb.0:
839+
; CHECK-NEXT: movq %rdi, %rax
840+
; CHECK-NEXT: movq (%rsi), %rcx
841+
; CHECK-NEXT: movq (%rdx), %r8
842+
; CHECK-NEXT: leaq (%rcx,%r8), %rdi
843+
; CHECK-NEXT: movq %rdi, (%rax)
844+
; CHECK-NEXT: movq 8(%rsi), %rdi
845+
; CHECK-NEXT: addq 8(%rdx), %rdi
846+
; CHECK-NEXT: setb %r9b
847+
; CHECK-NEXT: addq %r8, %rcx
848+
; CHECK-NEXT: adcq $0, %rdi
849+
; CHECK-NEXT: setb %cl
850+
; CHECK-NEXT: orb %r9b, %cl
851+
; CHECK-NEXT: movzbl %cl, %ecx
852+
; CHECK-NEXT: movq %rdi, 8(%rax)
853+
; CHECK-NEXT: movq 16(%rsi), %rsi
854+
; CHECK-NEXT: addq 16(%rdx), %rsi
855+
; CHECK-NEXT: addq %rcx, %rsi
856+
; CHECK-NEXT: movq %rsi, 16(%rax)
857+
; CHECK-NEXT: retq
858+
%4 = getelementptr inbounds %struct.U192, %struct.U192* %1, i64 0, i32 0, i64 0
859+
%5 = load i64, i64* %4, align 8
860+
%6 = getelementptr inbounds %struct.U192, %struct.U192* %2, i64 0, i32 0, i64 0
861+
%7 = load i64, i64* %6, align 8
862+
%8 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %5, i64 %7)
863+
%9 = extractvalue { i64, i1 } %8, 1
864+
%10 = extractvalue { i64, i1 } %8, 0
865+
%11 = zext i1 %9 to i64
866+
%12 = getelementptr inbounds %struct.U192, %struct.U192* %0, i64 0, i32 0, i64 0
867+
store i64 %10, i64* %12, align 8
868+
%13 = getelementptr inbounds %struct.U192, %struct.U192* %1, i64 0, i32 0, i64 1
869+
%14 = load i64, i64* %13, align 8
870+
%15 = getelementptr inbounds %struct.U192, %struct.U192* %2, i64 0, i32 0, i64 1
871+
%16 = load i64, i64* %15, align 8
872+
%17 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %14, i64 %16)
873+
%18 = extractvalue { i64, i1 } %17, 1
874+
%19 = extractvalue { i64, i1 } %17, 0
875+
%20 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %19, i64 %11)
876+
%21 = extractvalue { i64, i1 } %20, 1
877+
%22 = extractvalue { i64, i1 } %20, 0
878+
%23 = or i1 %18, %21
879+
%24 = zext i1 %23 to i64
880+
%25 = getelementptr inbounds %struct.U192, %struct.U192* %0, i64 0, i32 0, i64 1
881+
store i64 %22, i64* %25, align 8
882+
%26 = getelementptr inbounds %struct.U192, %struct.U192* %1, i64 0, i32 0, i64 2
883+
%27 = load i64, i64* %26, align 8
884+
%28 = getelementptr inbounds %struct.U192, %struct.U192* %2, i64 0, i32 0, i64 2
885+
%29 = load i64, i64* %28, align 8
886+
%30 = add i64 %27, %29
887+
%31 = add i64 %30, %24
888+
%32 = getelementptr inbounds %struct.U192, %struct.U192* %0, i64 0, i32 0, i64 2
889+
store i64 %31, i64* %32, align 8
890+
ret void
891+
}

llvm/test/CodeGen/X86/subcarry.ll

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
22
; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s
33

4-
declare { i64, i1 } @llvm.usub.with.overflow.i64(i64, i64) #1
4+
declare { i8, i64 } @llvm.x86.subborrow.64(i8, i64, i64)
5+
declare { i64, i1 } @llvm.usub.with.overflow.i64(i64, i64)
56

67
define i128 @sub128(i128 %a, i128 %b) nounwind {
78
; CHECK-LABEL: sub128:
@@ -384,3 +385,62 @@ define i32 @sub_U320_usubo(%struct.U320* nocapture dereferenceable(40) %0, i64 %
384385
%52 = zext i1 %51 to i32
385386
ret i32 %52
386387
}
388+
389+
%struct.U192 = type { [3 x i64] }
390+
391+
define void @PR39464(%struct.U192* noalias nocapture sret %0, %struct.U192* nocapture readonly dereferenceable(24) %1, %struct.U192* nocapture readonly dereferenceable(24) %2) {
392+
; CHECK-LABEL: PR39464:
393+
; CHECK: # %bb.0:
394+
; CHECK-NEXT: movq %rdi, %rax
395+
; CHECK-NEXT: movq (%rsi), %rcx
396+
; CHECK-NEXT: xorl %r9d, %r9d
397+
; CHECK-NEXT: subq (%rdx), %rcx
398+
; CHECK-NEXT: setb %r9b
399+
; CHECK-NEXT: movq %rcx, (%rdi)
400+
; CHECK-NEXT: movq 8(%rsi), %rdi
401+
; CHECK-NEXT: subq 8(%rdx), %rdi
402+
; CHECK-NEXT: setb %r8b
403+
; CHECK-NEXT: subq %r9, %rdi
404+
; CHECK-NEXT: setb %cl
405+
; CHECK-NEXT: orb %r8b, %cl
406+
; CHECK-NEXT: movzbl %cl, %ecx
407+
; CHECK-NEXT: movq %rdi, 8(%rax)
408+
; CHECK-NEXT: movq 16(%rsi), %rsi
409+
; CHECK-NEXT: subq 16(%rdx), %rsi
410+
; CHECK-NEXT: subq %rcx, %rsi
411+
; CHECK-NEXT: movq %rsi, 16(%rax)
412+
; CHECK-NEXT: retq
413+
%4 = getelementptr inbounds %struct.U192, %struct.U192* %1, i64 0, i32 0, i64 0
414+
%5 = load i64, i64* %4, align 8
415+
%6 = getelementptr inbounds %struct.U192, %struct.U192* %2, i64 0, i32 0, i64 0
416+
%7 = load i64, i64* %6, align 8
417+
%8 = tail call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %5, i64 %7)
418+
%9 = extractvalue { i64, i1 } %8, 1
419+
%10 = extractvalue { i64, i1 } %8, 0
420+
%11 = zext i1 %9 to i64
421+
%12 = getelementptr inbounds %struct.U192, %struct.U192* %0, i64 0, i32 0, i64 0
422+
store i64 %10, i64* %12, align 8
423+
%13 = getelementptr inbounds %struct.U192, %struct.U192* %1, i64 0, i32 0, i64 1
424+
%14 = load i64, i64* %13, align 8
425+
%15 = getelementptr inbounds %struct.U192, %struct.U192* %2, i64 0, i32 0, i64 1
426+
%16 = load i64, i64* %15, align 8
427+
%17 = tail call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %14, i64 %16)
428+
%18 = extractvalue { i64, i1 } %17, 1
429+
%19 = extractvalue { i64, i1 } %17, 0
430+
%20 = tail call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %19, i64 %11)
431+
%21 = extractvalue { i64, i1 } %20, 1
432+
%22 = extractvalue { i64, i1 } %20, 0
433+
%23 = or i1 %18, %21
434+
%24 = zext i1 %23 to i64
435+
%25 = getelementptr inbounds %struct.U192, %struct.U192* %0, i64 0, i32 0, i64 1
436+
store i64 %22, i64* %25, align 8
437+
%26 = getelementptr inbounds %struct.U192, %struct.U192* %1, i64 0, i32 0, i64 2
438+
%27 = load i64, i64* %26, align 8
439+
%28 = getelementptr inbounds %struct.U192, %struct.U192* %2, i64 0, i32 0, i64 2
440+
%29 = load i64, i64* %28, align 8
441+
%30 = sub i64 %27, %29
442+
%31 = sub i64 %30, %24
443+
%32 = getelementptr inbounds %struct.U192, %struct.U192* %0, i64 0, i32 0, i64 2
444+
store i64 %31, i64* %32, align 8
445+
ret void
446+
}

0 commit comments

Comments
 (0)