[llvm-commits] [Patch] Switch-to-lookup tables: do simple constant propagation

Duncan Sands baldrick at free.fr
Wed Oct 3 04:51:10 PDT 2012


Hi Hans,

> A patch [1] by Craig earlier this week pointed out that Clang fails to
> build lookup tables for switches like this:
>
>    switch(x) {
>      case 1: return 5;
>      case 2: return 42;
>      case 3: case 4: case 5:
>        return x - 123;
>      default: return 123;
>    }
>
> Where the resulting value for the 3, 4, 5 cases is "x - 123", rather
> than a constant.

maybe it is better to do this as part of some more generic switch simplification
logic rather than during table construction.

Ciao, Duncan.



More information about the llvm-commits mailing list