summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/Reassociate
diff options
context:
space:
mode:
authorAditya Nandakumar <aditya_nandakumar@apple.com>2016-01-26 18:42:36 +0000
committerAditya Nandakumar <aditya_nandakumar@apple.com>2016-01-26 18:42:36 +0000
commit3d0c46d489400c7a4fd1c06e3150a0c8fc0cca37 (patch)
tree647b3bde0dda692c966e5b7792a14b49f9338e0e /llvm/test/Transforms/Reassociate
parent3f81a9c654302eb984995441c56cb6af372b6a75 (diff)
downloadbcm5719-llvm-3d0c46d489400c7a4fd1c06e3150a0c8fc0cca37.tar.gz
bcm5719-llvm-3d0c46d489400c7a4fd1c06e3150a0c8fc0cca37.zip
Reassociate: Reprocess RedoInsts after each inst
Previously the RedoInsts was processed at the end of the block. However it was possible that it left behind some instructions that were not canonicalized. This should guarantee that any previous instruction in the basic block is canonicalized before we process a new instruction. llvm-svn: 258830
Diffstat (limited to 'llvm/test/Transforms/Reassociate')
-rw-r--r--llvm/test/Transforms/Reassociate/prev_insts_canonicalized.ll57
-rw-r--r--llvm/test/Transforms/Reassociate/reassoc-intermediate-fnegs.ll6
-rw-r--r--llvm/test/Transforms/Reassociate/xor_reassoc.ll4
3 files changed, 62 insertions, 5 deletions
diff --git a/llvm/test/Transforms/Reassociate/prev_insts_canonicalized.ll b/llvm/test/Transforms/Reassociate/prev_insts_canonicalized.ll
new file mode 100644
index 00000000000..649761e57c9
--- /dev/null
+++ b/llvm/test/Transforms/Reassociate/prev_insts_canonicalized.ll
@@ -0,0 +1,57 @@
+; RUN: opt < %s -reassociate -S | FileCheck %s
+
+; These tests make sure that before processing insts
+; any previous instructions are already canonicalized.
+define i32 @foo(i32 %in) {
+; CHECK-LABEL: @foo
+; CHECK-NEXT: %factor = mul i32 %in, -4
+; CHECK-NEXT: %factor1 = mul i32 %in, 2
+; CHECK-NEXT: %_3 = add i32 %factor, 1
+; CHECK-NEXT: %_5 = add i32 %_3, %factor1
+; CHECK-NEXT: ret i32 %_5
+ %_0 = add i32 %in, 1
+ %_1 = mul i32 %in, -2
+ %_2 = add i32 %_0, %_1
+ %_3 = add i32 %_1, %_2
+ %_4 = add i32 %_3, 1
+ %_5 = add i32 %in, %_3
+ ret i32 %_5
+}
+
+; CHECK-LABEL: @foo1
+define void @foo1(float %in, i1 %cmp) {
+wrapper_entry:
+ br label %foo1
+
+for.body:
+ %0 = fadd float %in1, %in1
+ br label %foo1
+
+foo1:
+ %_0 = fmul fast float %in, -3.000000e+00
+ %_1 = fmul fast float %_0, 3.000000e+00
+ %in1 = fadd fast float -3.000000e+00, %_1
+ %in1use = fadd fast float %in1, %in1
+ br label %for.body
+
+
+}
+
+; CHECK-LABEL: @foo2
+define void @foo2(float %in, i1 %cmp) {
+wrapper_entry:
+ br label %for.body
+
+for.body:
+; If the operands of the phi are sheduled for processing before
+; foo1 is processed, the invariant of reassociate are not preserved
+ %unused = phi float [%in1, %foo1], [undef, %wrapper_entry]
+ br label %foo1
+
+foo1:
+ %_0 = fmul fast float %in, -3.000000e+00
+ %_1 = fmul fast float %_0, 3.000000e+00
+ %in1 = fadd fast float -3.000000e+00, %_1
+ %in1use = fadd fast float %in1, %in1
+ br label %for.body
+}
diff --git a/llvm/test/Transforms/Reassociate/reassoc-intermediate-fnegs.ll b/llvm/test/Transforms/Reassociate/reassoc-intermediate-fnegs.ll
index c2cdffce61e..7d82ef7e7a2 100644
--- a/llvm/test/Transforms/Reassociate/reassoc-intermediate-fnegs.ll
+++ b/llvm/test/Transforms/Reassociate/reassoc-intermediate-fnegs.ll
@@ -1,8 +1,8 @@
; RUN: opt < %s -reassociate -S | FileCheck %s
; CHECK-LABEL: faddsubAssoc1
-; CHECK: [[TMP1:%tmp.*]] = fmul fast half %a, 0xH4500
-; CHECK: [[TMP2:%tmp.*]] = fmul fast half %b, 0xH4500
-; CHECK: fsub fast half [[TMP2]], [[TMP1]]
+; CHECK: [[TMP1:%.*]] = fsub fast half 0xH8000, %a
+; CHECK: [[TMP2:%.*]] = fadd fast half %b, [[TMP1]]
+; CHECK: fmul fast half [[TMP2]], 0xH4500
; CHECK: ret
; Input is A op (B op C)
define half @faddsubAssoc1(half %a, half %b) {
diff --git a/llvm/test/Transforms/Reassociate/xor_reassoc.ll b/llvm/test/Transforms/Reassociate/xor_reassoc.ll
index 0bed6f35880..a22689805fb 100644
--- a/llvm/test/Transforms/Reassociate/xor_reassoc.ll
+++ b/llvm/test/Transforms/Reassociate/xor_reassoc.ll
@@ -88,8 +88,8 @@ define i32 @xor_special2(i32 %x, i32 %y) {
%xor1 = xor i32 %xor, %and
ret i32 %xor1
; CHECK-LABEL: @xor_special2(
-; CHECK: %xor = xor i32 %x, 123
-; CHECK: %xor1 = xor i32 %xor, %y
+; CHECK: %xor = xor i32 %y, 123
+; CHECK: %xor1 = xor i32 %xor, %x
; CHECK: ret i32 %xor1
}
OpenPOWER on IntegriCloud