[PATCH] D52494: [InstCombine] Handle vector compares in foldGEPIcmp(), take 2

Jesper Antonsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 27 01:07:26 PDT 2018


JesperAntonsson added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:911
 
+      // If we're going to replace the ICmp, we must end up with the same type.
+      const auto& CompatibleAsICmp = [](Value* Src, Value* Dst) -> bool {
----------------
lebedev.ri wrote:
> I don't know it, but wouldn't it be possible to compare the types themselves directly?
> How does `icmp` ensure that the types are compatible?
With this patch, I'm trying to ensure the new and old ICmps have the same types, so that we can safely do replaceAllUsesWith(). That the two operands to the new ICmp have the same types is ensured already.

I can compare the ICmp types directly, but then I first have to create the new ICmp. What I do now is look at one operand of the new ICmp to check if it will get the same type as the old ICmp. E.g. if the old ICmp is {4 x i1] and the new operand is [4 x i16] then the new ICmp will have the same type as the old. 

Perhaps it'd be cleaner to create the ICmp and then delete it and move on if it doesn't have the same type? I'll prepare and upload a patch with that for comparison.


Repository:
  rL LLVM

https://reviews.llvm.org/D52494





More information about the llvm-commits mailing list