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

Gerolf Hoflehner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 1 18:04:21 PST 2016


Gerolf created this revision.
Gerolf added reviewers: sanjoy, majnemer.
Gerolf added a subscriber: llvm-commits.

This fixes an issue with switch narrowing that gets exposed
by r274233 ( https://reviews.llvm.org/D12965 - [InstCombine] shrink
switch conditions better (PR24766)). The problem is that case constants are
narrowed (to, say, width "k"), then the condition like cond = expr + const is
simplified by adding const to the case constants, and finally the new case
constants are narrowed again. However, when the width for the second round
of narrowing increases to, say, "k+n", then cond is a "k" bit expression
which won't match properly any "k+n" wide case constants.
The fix is to do the cond optimization first and only then narrow the case
constants appropriately.


https://reviews.llvm.org/D27327

Files:
  lib/Transforms/InstCombine/InstructionCombining.cpp
  test/Transforms/InstCombine/narrow-switch.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27327.80008.patch
Type: text/x-patch
Size: 4225 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161202/01648a0f/attachment.bin>


More information about the llvm-commits mailing list