[PATCH] D151617: A test case for the revision D151616

Paul Osmialowski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 27 11:57:08 PDT 2023


pawosm01 created this revision.
pawosm01 added a reviewer: qcolombet.
Herald added a project: All.
pawosm01 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This commit introduces a test for the change addressing the following
issue: https://github.com/llvm/llvm-project/issues/62736

The change commit itself should also remove the FIXME comment.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151617

Files:
  llvm/test/Transforms/Reassociate/reassociate-not-from-the-outside-of-the-loop.ll


Index: llvm/test/Transforms/Reassociate/reassociate-not-from-the-outside-of-the-loop.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/Reassociate/reassociate-not-from-the-outside-of-the-loop.ll
@@ -0,0 +1,44 @@
+; RUN: opt -passes=reassociate -S < %s | FileCheck %s
+
+; This test is to ensure that no computations are pulled into a loop
+; by the Reassociate pass. Doing so can result in the loop invariants not being
+; computed before the loop anymore. In case of this test, it would add an extra
+; multiplication into the loop.
+
+; FIXME: the checks below need to be inverted to confirm the change to the
+; Reassociate pass.
+
+define void @innermost_loop(i32 %i, double %d1, double %d2, double %delta, ptr %cells) {
+; CHECK-LABEL: @innermost_loop(
+entry:
+; CHECK-LABEL: entry:
+  %mul = fmul fast double %d1, %delta
+  %mul1 = fmul fast double %d2, %delta
+; CHECK-NOT: %{{.*}} = fmul {{.*}} %delta
+  br label %for.cond
+
+for.cond:
+  %j.0 = phi i32 [ 0, %entry ], [ %add, %for.body ]
+  %cmp.not = icmp sgt i32 %j.0, %i
+  br i1 %cmp.not, label %for.end, label %for.body
+
+for.body:
+; CHECK-LABEL: for.body:
+  %add = add nuw nsw i32 %j.0, 1
+  %idxprom = zext i32 %add to i64
+  %arrayidx = getelementptr inbounds double, ptr %cells, i64 %idxprom
+  %0 = load double, ptr %arrayidx
+  %mul2 = fmul fast double %mul, %0
+  %idxprom3 = zext i32 %j.0 to i64
+  %arrayidx4 = getelementptr inbounds double, ptr %cells, i64 %idxprom3
+  %1 = load double, ptr %arrayidx4
+  %mul5 = fmul fast double %mul1, %1
+  %add6 = fadd fast double %mul2, %mul5
+; CHECK: %reass{{.*}} = fadd
+; CHECK-NEXT: %reass{{.*}} = fmul {{.*}} %delta
+  store double %add6, ptr %arrayidx4
+  br label %for.cond
+
+for.end:
+  ret void
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151617.526281.patch
Type: text/x-patch
Size: 1787 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230527/fd33be40/attachment.bin>


More information about the llvm-commits mailing list