[PATCH] D142240: [LSR] Generalize one aspect of terminator folding (recently introduced in D132443)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 20 12:01:01 PST 2023


nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: StephenFan.

LG



================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:6714
     }
-    // TODO: Right now we limit the phi node to help the folding be of a start
-    // value of getelementptr. We can extend to any kinds of IV as long as it is
-    // an affine AddRec. Add a switch to cover more types of instructions here
-    // and down in the actual transformation.
-    return {isa<GetElementPtrInst>(PN.getIncomingValueForBlock(LoopPreheader)),
-            TermValueS};
+    return {true, TermValueS};
   };
----------------
reames wrote:
> nikic wrote:
> > The bool return value can be dropped -- check nullptr return instead.
> I plan to do this in a followup NFC.  There's a bunch of other simplification that follows, and some of the naming could stand cleaned up too.  
Sounds good.


================
Comment at: llvm/test/Transforms/LoopStrengthReduce/lsr-term-fold.ll:154
+; CHECK-NEXT:    [[TMP2:%.*]] = call ptr @foo(ptr [[TMP1]])
+; CHECK-NEXT:    [[INCDEC_PTR]] = getelementptr inbounds ptr, ptr [[DST_04]], i64 1
+; CHECK-NEXT:    [[LSR_FOLD_TERM_COND_REPLACED_TERM_COND:%.*]] = icmp eq ptr [[INCDEC_PTR]], [[UGLYGEP]]
----------------
This is a miscompile, but you are already know that...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142240/new/

https://reviews.llvm.org/D142240



More information about the llvm-commits mailing list