1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 3
2 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c99 %s -o - | FileCheck %s
3 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c11 %s -o - | FileCheck %s
4 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c17 %s -o - | FileCheck %s
5 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c23 %s -o - | FileCheck %s
7 // expected-no-diagnostics
10 #include <stdckdint.h>
12 // CHECK-LABEL: define dso_local zeroext i1 @test_ckd_add(
13 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
15 // CHECK-NEXT: [[RESULT:%.*]] = alloca i32, align 4
16 // CHECK-NEXT: [[TMP0:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 -1073741826, i32 -1073741826)
17 // CHECK-NEXT: [[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1
18 // CHECK-NEXT: [[TMP2:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0
19 // CHECK-NEXT: store i32 [[TMP2]], ptr [[RESULT]], align 4
20 // CHECK-NEXT: ret i1 [[TMP1]]
24 return ckd_add(&result
, -1073741826, -1073741826);
27 // CHECK-LABEL: define dso_local zeroext i1 @test_ckd_sub(
28 // CHECK-SAME: ) #[[ATTR0]] {
30 // CHECK-NEXT: [[RESULT:%.*]] = alloca i32, align 4
31 // CHECK-NEXT: [[TMP0:%.*]] = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 -1073741826, i32 1073741826)
32 // CHECK-NEXT: [[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1
33 // CHECK-NEXT: [[TMP2:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0
34 // CHECK-NEXT: store i32 [[TMP2]], ptr [[RESULT]], align 4
35 // CHECK-NEXT: ret i1 [[TMP1]]
39 return ckd_sub(&result
, -1073741826, 1073741826);
42 // CHECK-LABEL: define dso_local zeroext i1 @test_ckd_mul(
43 // CHECK-SAME: ) #[[ATTR0]] {
45 // CHECK-NEXT: [[RESULT:%.*]] = alloca i32, align 4
46 // CHECK-NEXT: [[TMP0:%.*]] = call { i32, i1 } @llvm.smul.with.overflow.i32(i32 -1073741826, i32 2)
47 // CHECK-NEXT: [[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1
48 // CHECK-NEXT: [[TMP2:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0
49 // CHECK-NEXT: store i32 [[TMP2]], ptr [[RESULT]], align 4
50 // CHECK-NEXT: ret i1 [[TMP1]]
54 return ckd_mul(&result
, -1073741826, 2);