Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Unified Diff: tests_lit/llvm2ice_tests/commutativity.ll

Issue 1371703003: Generate better two address code by using commutativity (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add test for commutativity. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests_lit/assembler/x86/opcode_register_encodings.ll ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests_lit/llvm2ice_tests/commutativity.ll
diff --git a/tests_lit/llvm2ice_tests/commutativity.ll b/tests_lit/llvm2ice_tests/commutativity.ll
new file mode 100644
index 0000000000000000000000000000000000000000..5baf3b02341764356acab20c6b8456add0c7fa34
--- /dev/null
+++ b/tests_lit/llvm2ice_tests/commutativity.ll
@@ -0,0 +1,106 @@
+; Test the lowering sequence for commutative operations. If there is a source
+; operand whose lifetime ends in an operation, it should be the first operand,
+; eliminating the need for a move to start the new lifetime.
+
+; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \
+; RUN: --target x8632 -i %s --args -O2 \
+; RUN: | %if --need=target_X8632 --command FileCheck %s
+
+declare void @useInteger(i32 %arg)
+declare void @useFloat(float %arg)
+
+define void @integerAddLeft(i32 %a, i32 %b) {
+entry:
+ %tmp = add i32 %a, %b
+ %result = add i32 %a, %tmp
+ tail call void @useInteger(i32 %result)
+ ret void
+}
+; CHECK-LABEL: integerAddLeft
+; CHECK-NOT: mov [[REG1:e.x]],[[REG2:e.x]]
Jim Stichnoth 2015/10/06 19:35:49 A few problems here. 1. You're matching eax/ebx/e
sehr 2015/10/07 00:18:30 Completely revamped per your comments here and in
+; CHECK: add [[REG1:e.x]],[[REG2:e.x]]
+; CHECK: add [[REG1:e.x]],[[REG2:e.x]]
+
+define void @integerAddRight(i32 %a, i32 %b) {
+entry:
+ %tmp = add i32 %a, %b
+ %result = add i32 %b, %tmp
+ tail call void @useInteger(i32 %result)
+ ret void
+}
+; CHECK-LABEL: integerAddRight
+; CHECK-NOT: mov [[REG1:e.x]],[[REG2:e.x]]
+; CHECK: add [[REG1:e.x]],[[REG2:e.x]]
+; CHECK: add [[REG1:e.x]],[[REG2:e.x]]
+
+define void @integerMultiplyLeft(i32 %a, i32 %b) {
+entry:
+ %tmp = mul i32 %a, %b
+ %result = mul i32 %a, %tmp
+ tail call void @useInteger(i32 %result)
+ ret void
+}
+; CHECK-LABEL: integerMultiplyLeft
+; CHECK-NOT: mov [[REG1:e.x]],[[REG2:e.x]]
+; CHECK: mul [[REG1:e.x]],[[REG2:e.x]]
+; CHECK: mul [[REG1:e.x]],[[REG2:e.x]]
+
+define void @integerMultiplyRight(i32 %a, i32 %b) {
+entry:
+ %tmp = mul i32 %a, %b
+ %result = mul i32 %b, %tmp
+ tail call void @useInteger(i32 %result)
+ ret void
+}
+; CHECK-LABEL: integerMultiplyRight
+; CHECK-NOT: mov [[REG1:e.x]],[[REG2:e.x]]
+; CHECK: mul [[REG1:e.x]],[[REG2:e.x]]
+; CHECK: mul [[REG1:e.x]],[[REG2:e.x]]
+
+define void @floatAddLeft(float %a, float %b) {
+entry:
+ %tmp = fadd float %a, %b
+ %result = fadd float %a, %tmp
+ tail call void @useFloat(float %result)
+ ret void
+}
+; CHECK-LABEL: floatAddLeft
+; CHECK-NOT: movss [[REG1:xmm.]],[[REG2:xmm.]]
+; CHECK: addss [[REG1:xmm.]],[[REG2:xmm.]]
+; CHECK: addss [[REG1:xmm.]],[[REG2:xmm.]]
+
+define void @floatAddRight(float %a, float %b) {
+entry:
+ %tmp = fadd float %a, %b
+ %result = fadd float %b, %tmp
+ tail call void @useFloat(float %result)
+ ret void
+}
+; CHECK-LABEL: floatAddRight
+; CHECK-NOT: movss [[REG1:xmm.]],[[REG2:xmm.]]
+; CHECK: addss [[REG1:xmm.]],[[REG2:xmm.]]
+; CHECK: addss [[REG1:xmm.]],[[REG2:xmm.]]
+
+define void @floatMultiplyLeft(float %a, float %b) {
+entry:
+ %tmp = fmul float %a, %b
+ %result = fmul float %a, %tmp
+ tail call void @useFloat(float %result)
+ ret void
+}
+; CHECK-LABEL: floatMultiplyLeft
+; CHECK-NOT: movss [[REG1:xmm.]],[[REG2:xmm.]]
+; CHECK: mulss [[REG1:xmm.]],[[REG2:xmm.]]
+; CHECK: mulss [[REG1:xmm.]],[[REG2:xmm.]]
+
+define void @floatMultiplyRight(float %a, float %b) {
+entry:
+ %tmp = fmul float %a, %b
+ %result = fmul float %b, %tmp
+ tail call void @useFloat(float %result)
+ ret void
+}
+; CHECK-LABEL: floatMultiplyRight
+; CHECK-NOT: movss [[REG1:xmm.]],[[REG2:xmm.]]
+; CHECK: mulss [[REG1:xmm.]],[[REG2:xmm.]]
+; CHECK: mulss [[REG1:xmm.]],[[REG2:xmm.]]
« no previous file with comments | « tests_lit/assembler/x86/opcode_register_encodings.ll ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698