[InstCombine][x86] add tests for addcarry intrinsic; NFC
authorSanjay Patel <spatel@rotateright.com>
Wed, 30 Jan 2019 15:07:49 +0000 (15:07 +0000)
committerSanjay Patel <spatel@rotateright.com>
Wed, 30 Jan 2019 15:07:49 +0000 (15:07 +0000)
llvm-svn: 352627

llvm/test/Transforms/InstCombine/X86/addcarry.ll [new file with mode: 0644]

diff --git a/llvm/test/Transforms/InstCombine/X86/addcarry.ll b/llvm/test/Transforms/InstCombine/X86/addcarry.ll
new file mode 100644 (file)
index 0000000..5f5fc04
--- /dev/null
@@ -0,0 +1,36 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+declare { i8, i32 } @llvm.x86.addcarry.32(i8, i32, i32)
+declare { i8, i64 } @llvm.x86.addcarry.64(i8, i64, i64)
+
+define i32 @no_carryin_i32(i32 %x, i32 %y, i8* %p) {
+; CHECK-LABEL: @no_carryin_i32(
+; CHECK-NEXT:    [[S:%.*]] = call { i8, i32 } @llvm.x86.addcarry.32(i8 0, i32 [[X:%.*]], i32 [[Y:%.*]])
+; CHECK-NEXT:    [[OV:%.*]] = extractvalue { i8, i32 } [[S]], 0
+; CHECK-NEXT:    store i8 [[OV]], i8* [[P:%.*]], align 1
+; CHECK-NEXT:    [[R:%.*]] = extractvalue { i8, i32 } [[S]], 1
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %s = call { i8, i32 } @llvm.x86.addcarry.32(i8 0, i32 %x, i32 %y)
+  %ov = extractvalue { i8, i32 } %s, 0
+  store i8 %ov, i8* %p
+  %r = extractvalue { i8, i32 } %s, 1
+  ret i32 %r
+}
+
+define i64 @no_carryin_i64(i64 %x, i64 %y, i8* %p) {
+; CHECK-LABEL: @no_carryin_i64(
+; CHECK-NEXT:    [[S:%.*]] = call { i8, i64 } @llvm.x86.addcarry.64(i8 0, i64 [[X:%.*]], i64 [[Y:%.*]])
+; CHECK-NEXT:    [[OV:%.*]] = extractvalue { i8, i64 } [[S]], 0
+; CHECK-NEXT:    store i8 [[OV]], i8* [[P:%.*]], align 1
+; CHECK-NEXT:    [[R:%.*]] = extractvalue { i8, i64 } [[S]], 1
+; CHECK-NEXT:    ret i64 [[R]]
+;
+  %s = call { i8, i64 } @llvm.x86.addcarry.64(i8 0, i64 %x, i64 %y)
+  %ov = extractvalue { i8, i64 } %s, 0
+  store i8 %ov, i8* %p
+  %r = extractvalue { i8, i64 } %s, 1
+  ret i64 %r
+}
+