diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGen/builtins-ppc-altivec.c | 6 | ||||
-rw-r--r-- | test/CodeGen/exprs.c | 15 | ||||
-rw-r--r-- | test/CodeGen/extern-inline.c | 2 | ||||
-rw-r--r-- | test/CodeGen/integer-overflow.c | 33 |
4 files changed, 38 insertions, 18 deletions
diff --git a/test/CodeGen/builtins-ppc-altivec.c b/test/CodeGen/builtins-ppc-altivec.c index 1ffb05905a..4b9c3d5c42 100644 --- a/test/CodeGen/builtins-ppc-altivec.c +++ b/test/CodeGen/builtins-ppc-altivec.c @@ -428,13 +428,13 @@ int main () res_vus = vec_mladd(vus, vus, vus); // CHECK: mul <8 x i16> // CHECK: add <8 x i16> - res_vs = vec_mladd(vus, vs, vs); // CHECK: mul <8 x i16> + res_vs = vec_mladd(vus, vs, vs); // CHECK: mul nsw <8 x i16> // CHECK: add nsw <8 x i16> - res_vs = vec_mladd(vs, vus, vus); // CHECK: mul <8 x i16> + res_vs = vec_mladd(vs, vus, vus); // CHECK: mul nsw <8 x i16> // CHECK: add nsw <8 x i16> - res_vs = vec_mladd(vs, vs, vs); // CHECK: mul <8 x i16> + res_vs = vec_mladd(vs, vs, vs); // CHECK: mul nsw <8 x i16> // CHECK: add nsw <8 x i16> /* vec_mradds */ diff --git a/test/CodeGen/exprs.c b/test/CodeGen/exprs.c index a90ae58dc3..d182ce81ca 100644 --- a/test/CodeGen/exprs.c +++ b/test/CodeGen/exprs.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -emit-llvm -o - // PR1895 // sizeof function @@ -119,16 +119,3 @@ void f9(struct S *x) { void f10() { __builtin_sin(0); } - -// Tests for signed integer overflow stuff. -// rdar://7432000 -void f11() { - // CHECK: define void @f11 - extern volatile int f11G, a, b; - // CHECK: add nsw i32 - f11G = a + b; - // CHECK: sub nsw i32 - f11G = a - b; - // CHECK: sub nsw i32 0, - f11G = -a; -} diff --git a/test/CodeGen/extern-inline.c b/test/CodeGen/extern-inline.c index 5dd9bfda57..60f6d034bf 100644 --- a/test/CodeGen/extern-inline.c +++ b/test/CodeGen/extern-inline.c @@ -19,7 +19,7 @@ int g2(void) {return f2(0,1);} static int f2(int a, int b) {return a*b;} // CHECK: load i32* %{{.*}} // CHECK: load i32* %{{.*}} -// CHECK: mul i32 %{{.*}}, %{{.*}} +// CHECK: mul nsw i32 %{{.*}}, %{{.*}} int h2(void) {return f2(1,2);} // CHECK: call i32 @f2 diff --git a/test/CodeGen/integer-overflow.c b/test/CodeGen/integer-overflow.c new file mode 100644 index 0000000000..7969216104 --- /dev/null +++ b/test/CodeGen/integer-overflow.c @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT +// RUN: %clang_cc1 %s -emit-llvm -o - -fwrapv | FileCheck %s --check-prefix=WRAPV +// RUN: %clang_cc1 %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=TRAPV + + +// Tests for signed integer overflow stuff. +// rdar://7432000 rdar://7221421 +void test1() { + // DEFAULT: define void @test1 + // WRAPV: define void @test1 + // TRAPV: define void @test1 + extern volatile int f11G, a, b; + + // DEFAULT: add nsw i32 + // WRAPV: add i32 + // TRAPV: llvm.sadd.with.overflow.i32 + f11G = a + b; + + // DEFAULT: sub nsw i32 + // WRAPV: sub i32 + // TRAPV: llvm.ssub.with.overflow.i32 + f11G = a - b; + + // DEFAULT: sub nsw i32 0, + // WRAPV: sub i32 0, + // TRAPV: sub nsw i32 0, + f11G = -a; + + // DEFAULT: mul nsw i32 + // WRAPV: mul i32 + // TRAPV: llvm.smul.with.overflow.i32 + f11G = a * b; +} |