From fe4432b105665badd6a88a120767864e4a2efbae Mon Sep 17 00:00:00 2001 From: Oliver Stannard Date: Mon, 17 Oct 2016 12:00:24 +0000 Subject: [SimplifyCFG] Don't lower complex ConstantExprs to lookup tables Not all ConstantExprs can be represented by a global variable, for example most pointer arithmetic other than addition of a constant, so we can't convert these values from switch statements to lookup tables. Differential Revision: https://reviews.llvm.org/D25550 llvm-svn: 284379 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp') diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 21bb87b84fc..c7c66fd9d74 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -4449,9 +4449,12 @@ static bool ValidLookupTableConstant(Constant *C, const TargetTransformInfo &TTI !isa(C) && !isa(C)) return false; - if (ConstantExpr *CE = dyn_cast(C)) + if (ConstantExpr *CE = dyn_cast(C)) { if (!CE->isGEPWithNoNotionalOverIndexing()) return false; + if (!ValidLookupTableConstant(CE->getOperand(0), TTI)) + return false; + } if (!TTI.shouldBuildLookupTablesForConstant(C)) return false; -- cgit v1.2.3