summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen
diff options
context:
space:
mode:
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2014-06-09 12:34:50 +0000
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2014-06-09 12:34:50 +0000
commitdfbdc71ea1bf22c72422afa97948df90bc0a0eb2 (patch)
treefddaf28a0d768e767158a412d8f33df5501997f4 /llvm/test/CodeGen
parent4db1abea150d7cfdbb7f4f402103f3d84d27ba28 (diff)
downloadbcm5719-llvm-dfbdc71ea1bf22c72422afa97948df90bc0a0eb2.tar.gz
bcm5719-llvm-dfbdc71ea1bf22c72422afa97948df90bc0a0eb2.zip
[X86] Avoid emitting unnecessary test instructions.
This patch teaches the backend how to check for the 'NoSignedWrap' flag on binary operations to improve the emission of 'test' instructions. If the result of a binary operation is known not to overflow we know that resetting the Overflow flag is unnecessary and so we can avoid emitting the test instruction. Patch by Marcello Maggioni. llvm-svn: 210468
Diffstat (limited to 'llvm/test/CodeGen')
-rw-r--r--llvm/test/CodeGen/X86/2014-05-29-factorial.ll24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/2014-05-29-factorial.ll b/llvm/test/CodeGen/X86/2014-05-29-factorial.ll
new file mode 100644
index 00000000000..70255bd3219
--- /dev/null
+++ b/llvm/test/CodeGen/X86/2014-05-29-factorial.ll
@@ -0,0 +1,24 @@
+; RUN: llc < %s -march=x86-64 | FileCheck %s
+; CHECK: decq %rdi
+; CHECK-NOT: testq %rdi, %rdi
+
+define i64 @fact2(i64 %x) {
+entry:
+ br label %while.body
+
+while.body:
+ %result.06 = phi i64 [ %mul, %while.body ], [ 1, %entry ]
+ %x.addr.05 = phi i64 [ %dec, %while.body ], [ %x, %entry ]
+ %mul = mul nsw i64 %result.06, %x.addr.05
+ %dec = add nsw i64 %x.addr.05, -1
+ %cmp = icmp sgt i64 %dec, 0
+ br i1 %cmp, label %while.body, label %while.end.loopexit
+
+while.end.loopexit:
+ %mul.lcssa = phi i64 [ %mul, %while.body ]
+ br label %while.end
+
+while.end:
+ %result.0.lcssa = phi i64 [ %mul.lcssa, %while.end.loopexit ]
+ ret i64 %result.0.lcssa
+}
OpenPOWER on IntegriCloud