[PATCH] D25550: [SimplifyCFG] Don't lower complex ConstantExprs to lookup tables
Oliver Stannard via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 17 05:09:52 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284379: [SimplifyCFG] Don't lower complex ConstantExprs to lookup tables (authored by olista01).
Changed prior to commit:
https://reviews.llvm.org/D25550?vs=74627&id=74828#toc
Repository:
rL LLVM
https://reviews.llvm.org/D25550
Files:
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/trunk/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table-constant-expr.ll
Index: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -4449,9 +4449,12 @@
!isa<UndefValue>(C) && !isa<ConstantExpr>(C))
return false;
- if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
+ if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
if (!CE->isGEPWithNoNotionalOverIndexing())
return false;
+ if (!ValidLookupTableConstant(CE->getOperand(0), TTI))
+ return false;
+ }
if (!TTI.shouldBuildLookupTablesForConstant(C))
return false;
Index: llvm/trunk/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table-constant-expr.ll
===================================================================
--- llvm/trunk/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table-constant-expr.ll
+++ llvm/trunk/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table-constant-expr.ll
@@ -0,0 +1,40 @@
+; RUN: opt -S -simplifycfg < %s | FileCheck %s --check-prefix=CHECK
+
+target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+target triple = "armv7a--none-eabi"
+
+; One of the phi node's values is too complex to be represented by a global
+; variable, so we can't convert to a lookup table.
+
+; CHECK-NOT: @switch.table
+; CHECK-NOT: load
+
+ at g1 = external global i32, align 4
+ at g2 = external global i32, align 4
+ at g3 = external global i32, align 4
+ at g4 = external thread_local global i32, align 4
+
+define i32* @test3(i32 %n) {
+entry:
+ switch i32 %n, label %sw.default [
+ i32 0, label %sw.bb
+ i32 1, label %sw.bb1
+ i32 2, label %sw.bb2
+ ]
+
+sw.bb:
+ br label %return
+
+sw.bb1:
+ br label %return
+
+sw.bb2:
+ br label %return
+
+sw.default:
+ br label %return
+
+return:
+ %retval.0 = phi i32* [ @g4, %sw.default ], [ getelementptr inbounds (i32, i32* inttoptr (i32 mul (i32 ptrtoint (i32* @g3 to i32), i32 2) to i32*), i32 1), %sw.bb2 ], [ @g2, %sw.bb1 ], [ @g1, %sw.bb ]
+ ret i32* %retval.0
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25550.74828.patch
Type: text/x-patch
Size: 2053 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161017/1a885bb8/attachment.bin>
More information about the llvm-commits
mailing list