[cfe-commits] r165129 - /cfe/trunk/test/CodeGen/atom-idiv-bypass.c

Preston Gurd preston.gurd at intel.com
Wed Oct 3 09:37:56 PDT 2012


Author: pgurd
Date: Wed Oct  3 11:37:56 2012
New Revision: 165129

URL: http://llvm.org/viewvc/llvm-project?rev=165129&view=rev
Log:
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.


Added:
    cfe/trunk/test/CodeGen/atom-idiv-bypass.c

Added: cfe/trunk/test/CodeGen/atom-idiv-bypass.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/atom-idiv-bypass.c?rev=165129&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/atom-idiv-bypass.c (added)
+++ cfe/trunk/test/CodeGen/atom-idiv-bypass.c Wed Oct  3 11:37:56 2012
@@ -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;
+}





More information about the cfe-commits mailing list