[PATCH] D12965: [InstCombine] shrink switch conditions better (PR24766)

hfinkel@anl.gov via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 18 16:36:53 PDT 2015


hfinkel added a comment.

> FWIW, I don't see any perf difference on test-suite on x86 with this change, and I'm not sure how the supposed extra zext x86 instructions would hurt anyway.


Okay, but I'm still hesitant to generate unnecessary instructions. Do we still end up with the unnecessary zext instructions with this patch?


================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:2160
@@ +2159,3 @@
+    Type *NewType = Type::getIntNTy(SI.getContext(), NewWidth);
+    if (ShouldChangeType(Ty, NewType)) {
+      TruncCond = true;
----------------
I think it would be better to refactor InstCombiner::ShouldChangeType to have a version that directly takes the bit widths. ShouldChangeType just calls getPrimitiveSizeInBits on the provided types anyway, and that prevents the need to speculatively call Type::getIntNTy.


http://reviews.llvm.org/D12965





More information about the llvm-commits mailing list