[PATCH] D27327: [InstCombine] Fix to switch narrowing

Hans Wennborg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 9 10:24:30 PST 2016


hans added a comment.

I'm sorry, but I'm having trouble fully understanding exactly what the bug is that this is fixing.

It seems that this patch is regressing the `@trunc64to59` test since we're now failing to truncate the condition to `i59`.

It does seem reasonable to optimize the `switch (x + C)` before doing truncation, so this is probably the right thing to do, I'd just like to understand it better.

And if we're going to do truncation after we've changed the switch condition, don't we need to move the `computeKnownBits` part as well? With your patch, we're first computing known bits of the condition, then changing the condition, and then later using those known bits. That seems wrong.



================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:2276
-      Constant *LHS = CaseVal;
-      if (TruncCond) {
-        LHS = LeadingKnownZeros
----------------
Gerolf wrote:
> hans wrote:
> > What happened to this part?
> Gone as part of the fix: the condition expression a+const is evaluated at full width before the case constants are inspected. 
Oh, I see now.


https://reviews.llvm.org/D27327





More information about the llvm-commits mailing list