diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-07-29 03:27:26 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-07-29 03:27:26 +0000 |
commit | d536f2328ededb3aae6563c721c6134c735f1918 (patch) | |
tree | 3d65c25e2093384cf070d6f3b8be9f9eaffbac78 /llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp | |
parent | c7de3a101885c5b9b167a82b0be37dfb23551aa2 (diff) | |
download | bcm5719-llvm-d536f2328ededb3aae6563c721c6134c735f1918.tar.gz bcm5719-llvm-d536f2328ededb3aae6563c721c6134c735f1918.zip |
[ConstnatFolding] Teach the folder how to fold ConstantVector
A ConstantVector can have ConstantExpr operands and vice versa.
However, the folder had no ability to fold ConstantVectors which, in
some cases, was an optimization barrier.
Instead, rephrase the folder in terms of Constants instead of
ConstantExprs and teach callers how to deal with failure.
llvm-svn: 277099
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp index 08e16a7ee1a..279eaad0174 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp @@ -194,8 +194,10 @@ static Value *GetShiftedValue(Value *V, unsigned NumBits, bool isLeftShift, else V = IC.Builder->CreateLShr(C, NumBits); // If we got a constantexpr back, try to simplify it with TD info. - if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) - V = ConstantFoldConstantExpression(CE, DL, IC.getTargetLibraryInfo()); + if (auto *C = dyn_cast<Constant>(V)) + if (auto *FoldedC = + ConstantFoldConstant(C, DL, IC.getTargetLibraryInfo())) + V = FoldedC; return V; } |