summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2014-06-09 12:32:53 +0000
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2014-06-09 12:32:53 +0000
commit4db1abea150d7cfdbb7f4f402103f3d84d27ba28 (patch)
tree8dbb67824b4645f035afabbabb7fd11d0c541cb0 /llvm/test
parent5260dba32346bdaec7277eed9f24b0c121e55e8b (diff)
downloadbcm5719-llvm-4db1abea150d7cfdbb7f4f402103f3d84d27ba28.tar.gz
bcm5719-llvm-4db1abea150d7cfdbb7f4f402103f3d84d27ba28.zip
[DAG] Expose NoSignedWrap, NoUnsignedWrap and Exact flags to SelectionDAG.
This patch modifies SelectionDAGBuilder to construct SDNodes with associated NoSignedWrap, NoUnsignedWrap and Exact flags coming from IR BinaryOperator instructions. Added a new SDNode type called 'BinaryWithFlagsSDNode' to allow accessing nsw/nuw/exact flags during codegen. Patch by Marcello Maggioni. llvm-svn: 210467
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/CodeGen/X86/2014-05-30-CombineAddNSW.ll20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/2014-05-30-CombineAddNSW.ll b/llvm/test/CodeGen/X86/2014-05-30-CombineAddNSW.ll
new file mode 100644
index 00000000000..4580795880a
--- /dev/null
+++ b/llvm/test/CodeGen/X86/2014-05-30-CombineAddNSW.ll
@@ -0,0 +1,20 @@
+; RUN: llc < %s -march=x86-64 | FileCheck %s
+; CHECK: addl
+
+; The two additions are the same , but have different flags.
+; In theory this code should never be generated by the frontend, but this
+; tries to test that two identical instructions with two different flags
+; actually generate two different nodes.
+;
+; Normally the combiner would see this condition without the flags
+; and optimize the result of the sub into a register clear
+; (the final result would be 0). With the different flags though the combiner
+; needs to keep the add + sub nodes, because the two nodes result as different
+; nodes and so cannot assume that the subtraction of the two nodes
+; generates 0 as result
+define i32 @foo(i32 %a, i32 %b) {
+ %1 = add i32 %a, %b
+ %2 = add nsw i32 %a, %b
+ %3 = sub i32 %1, %2
+ ret i32 %3
+}
OpenPOWER on IntegriCloud