summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen
diff options
context:
space:
mode:
authorPreston Gurd <preston.gurd@intel.com>2012-10-03 16:37:56 +0000
committerPreston Gurd <preston.gurd@intel.com>2012-10-03 16:37:56 +0000
commita3d7df6fee322f2276ddc841c2d2e291be79680c (patch)
tree968d0f274ab9fe62a017bdb40f0d19ec3ae52568 /clang/test/CodeGen
parent471cbb73f87f83b511cc1f453944ea9b6e1206a1 (diff)
downloadbcm5719-llvm-a3d7df6fee322f2276ddc841c2d2e291be79680c.tar.gz
bcm5719-llvm-a3d7df6fee322f2276ddc841c2d2e291be79680c.zip
Adds a test to verify that Clang does the optimization to use a
fast div/rem instruction (for Intel Atom). Test case for llvm commit 165126. Patch by Tyler Nowicki. llvm-svn: 165129
Diffstat (limited to 'clang/test/CodeGen')
-rw-r--r--clang/test/CodeGen/atom-idiv-bypass.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/clang/test/CodeGen/atom-idiv-bypass.c b/clang/test/CodeGen/atom-idiv-bypass.c
new file mode 100644
index 00000000000..596e18b01c2
--- /dev/null
+++ b/clang/test/CodeGen/atom-idiv-bypass.c
@@ -0,0 +1,32 @@
+// This test verifies that IDIV bypass optimizations is used when compiling for
+// Atom processors with O2. The optimization inserts a test followed by a
+// branch to bypass the slow IDIV instruction. This test verifies that global
+// context types are used when comparing with those in the BypassTypeMap.
+
+// RUN: %clang_cc1 %s -march=atom -m32 -O2 -S -o - | FileCheck %s
+// CHECK: div32
+// CHECK: orl
+// CHECK: testl
+// CHECK: je
+// CHECK: idivl
+// CHECK: ret
+// CHECK: divb
+// CHECK: ret
+int div32(int a, int b)
+{
+ return a/b;
+}
+
+// CHECK: divrem32
+// CHECK: orl
+// CHECK: testl
+// CHECK: je
+// CHECK: idivl
+// CHECK: jmp
+// CHECK: divb
+// CHECK: addl
+// CHECK: ret
+int divrem32(int a, int b)
+{
+ return a/b + a%b;
+}
OpenPOWER on IntegriCloud