[PATCH] D109565: Teach SimplifyCFG to fold switches into lookup tables in more cases.
Owen Anderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 12 23:13:47 PDT 2021
resistor added inline comments.
================
Comment at: llvm/test/Transforms/SimplifyCFG/switch-to-lookup-bitcast.ll:3
+; RUN: opt -simplifycfg --switch-to-lookup -S < %s | FileCheck %s
+target triple = "x86_64-unknown-linux-gnu"
+
----------------
nikic wrote:
> This target triple either needs to be dropped (if the test works without it), or the test should be moved in to the X86 subdirectory.
The test does not work without it.
================
Comment at: llvm/test/Transforms/SimplifyCFG/switch-to-lookup-gep.ll:80
+bb14:
+ %.sroa.0.0 = phi [0 x i8]* [ getelementptr inbounds ([0 x i8], [0 x i8]* bitcast (<{ [1 x i8] }>* @alloc25 to [0 x i8]*), i32 0), %bb1 ], [ bitcast (<{ [1 x i8] }>* @alloc26 to [0 x i8]*), %bb13 ], [ bitcast (<{ [1 x i8] }>* @alloc27 to [0 x i8]*), %bb12 ], [ bitcast (<{ [1 x i8] }>* @alloc28 to [0 x i8]*), %bb11 ], [ bitcast (<{ [1 x i8] }>* @alloc29 to [0 x i8]*), %bb10 ], [ bitcast (<{ [1 x i8] }>* @alloc30 to [0 x i8]*), %bb9 ], [ bitcast (<{ [1 x i8] }>* @alloc31 to [0 x i8]*), %bb8 ], [ bitcast (<{ [1 x i8] }>* @alloc32 to [0 x i8]*), %bb7 ], [ bitcast (<{ [1 x i8] }>* @alloc33 to [0 x i8]*), %bb6 ], [ bitcast (<{ [1 x i8] }>* @alloc34 to [0 x i8]*), %bb5 ], [ bitcast (<{ [1 x i8] }>* @alloc35 to [0 x i8]*), %bb4 ], [ bitcast (<{ [1 x i8] }>* @alloc36 to [0 x i8]*), %start ]
+ %1 = insertvalue { [0 x i8]*, i64 } undef, [0 x i8]* %.sroa.0.0, 0
----------------
nikic wrote:
> This only tests a GEP with a zero offset, which is a degenerate case. It would be better to test a non-zero offset.
>
> We could also have a negative test that no lookup table is created if a GEP index is not a constant integer (but rather something like `ptrtoint i8* @g to i64`.
Updated test to use non-zero offsets. The proposed negative test doesn't fail, and it's not clear to me that it should fail.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109565/new/
https://reviews.llvm.org/D109565
More information about the llvm-commits
mailing list