[PATCH] D39906: [InstCombine] Allowing GEP Instructions with loop Invariant operands to combine

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 10 11:23:12 PST 2017


efriedma added a comment.

See also https://reviews.llvm.org/D8911 / https://bugs.llvm.org/show_bug.cgi?id=23163, which originally introduced this check.  I don't think checking whether the operands are loop-invariant really solves that problem... you still get exactly the same code duplication, just not inside the innermost loop.



================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:1703
+            if ((!isa<Constant>(GO1) && !(L->isLoopInvariant(GO1))) ||
+                (!isa<Constant>(SO1) && !(L->isLoopInvariant(SO1))))
+              return nullptr;
----------------
Constants are loop-invariant; no need to check for them explicitly.


================
Comment at: test/Transforms/InstCombine/gep-combine-loop-invariant.ll:2
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -licm -S | FileCheck %s
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
----------------
Please write tests to only run one pass; putting multiple passes in the RUN line makes it confusing to figure out what you're actually expecting each individual pass to do.  (You can add a comment to explain, if it isn't obvious why a transform is profitable.)


https://reviews.llvm.org/D39906





More information about the llvm-commits mailing list