[PATCH] D27413: Simplify gep (gep p, a), (b-a)

Davide Italiano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 16 17:11:00 PST 2016

davide added inline comments.

Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:1566-1570
+      Value* Sum = SimplifyAddInst(GO1, SO1, false, false, DL, &TLI, &DT, &AC);
+      // Only do the combine when we are sure the cost after the
+      // merge is never more than that before the merge.
+      if (Sum == nullptr)
+        return nullptr;
ranma42 wrote:
> davide wrote:
> > You can fold the `SimplifyAddInst` inside the if, no?
> As in
> ```
>   if (!(Sum = SimplifyAddInst(GO1, SO1, false, false, DL, &TLI, &DT, &AC)))
> ```
> ?
> I was afraid that it was less readable, but I can definitely do that :)
up to you.  The API is actually quite verbose already because it takes a lot of arguments. Anyway, I'm OK with this but please wait for others to comment.


More information about the llvm-commits mailing list