summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-06-26 21:25:03 +0000
committerChris Lattner <sabre@nondot.org>2010-06-26 21:25:03 +0000
commit51924e517bd2d25faea6ef873db3c59ec4d09bf8 (patch)
tree7d971b3e55a000a23d28dac62cc985f20f05be06 /clang/test/CodeGen
parent217e056e409f51bc64a82334e72bed0f14a51270 (diff)
downloadbcm5719-llvm-51924e517bd2d25faea6ef873db3c59ec4d09bf8.tar.gz
bcm5719-llvm-51924e517bd2d25faea6ef873db3c59ec4d09bf8.zip
Implement support for -fwrapv, rdar://7221421
As part of this, pull together trapv handling into the same enum. This also add support for NSW multiplies. This also makes PCH disagreement on overflow behavior silent, since it really doesn't matter except for warnings and codegen (no macros get defined etc). llvm-svn: 106956
Diffstat (limited to 'clang/test/CodeGen')
-rw-r--r--clang/test/CodeGen/builtins-ppc-altivec.c6
-rw-r--r--clang/test/CodeGen/exprs.c15
-rw-r--r--clang/test/CodeGen/extern-inline.c2
-rw-r--r--clang/test/CodeGen/integer-overflow.c33
4 files changed, 38 insertions, 18 deletions
diff --git a/clang/test/CodeGen/builtins-ppc-altivec.c b/clang/test/CodeGen/builtins-ppc-altivec.c
index 1ffb05905af..4b9c3d5c422 100644
--- a/clang/test/CodeGen/builtins-ppc-altivec.c
+++ b/clang/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/clang/test/CodeGen/exprs.c b/clang/test/CodeGen/exprs.c
index a90ae58dc3f..d182ce81cab 100644
--- a/clang/test/CodeGen/exprs.c
+++ b/clang/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/clang/test/CodeGen/extern-inline.c b/clang/test/CodeGen/extern-inline.c
index 5dd9bfda574..60f6d034bf1 100644
--- a/clang/test/CodeGen/extern-inline.c
+++ b/clang/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/clang/test/CodeGen/integer-overflow.c b/clang/test/CodeGen/integer-overflow.c
new file mode 100644
index 00000000000..79692161042
--- /dev/null
+++ b/clang/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;
+}
OpenPOWER on IntegriCloud