From 3b2fe1d8f651491ae9451ce04761c8b4a4c9b1bf Mon Sep 17 00:00:00 2001 From: Ilia Filippov Date: Tue, 21 Jan 2014 17:26:05 +0400 Subject: [PATCH] adding patch for LLVM. Fix for trunk(select) --- .../3_3_3_4_r198267_trunc_of_select.patch | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 llvm_patches/3_3_3_4_r198267_trunc_of_select.patch diff --git a/llvm_patches/3_3_3_4_r198267_trunc_of_select.patch b/llvm_patches/3_3_3_4_r198267_trunc_of_select.patch new file mode 100644 index 00000000..f6a43b3d --- /dev/null +++ b/llvm_patches/3_3_3_4_r198267_trunc_of_select.patch @@ -0,0 +1,34 @@ +Index: lib/IR/ConstantFold.cpp +=================================================================== +--- lib/IR/ConstantFold.cpp (revision 197981) ++++ lib/IR/ConstantFold.cpp (working copy) +@@ -705,12 +705,23 @@ + SmallVector Result; + Type *Ty = IntegerType::get(CondV->getContext(), 32); + for (unsigned i = 0, e = V1->getType()->getVectorNumElements(); i != e;++i){ +- ConstantInt *Cond = dyn_cast(CondV->getOperand(i)); +- if (Cond == 0) break; +- +- Constant *V = Cond->isNullValue() ? V2 : V1; +- Constant *Res = ConstantExpr::getExtractElement(V, ConstantInt::get(Ty, i)); +- Result.push_back(Res); ++ Constant *V; ++ Constant *V1Element = ConstantExpr::getExtractElement(V1, ++ ConstantInt::get(Ty, i)); ++ Constant *V2Element = ConstantExpr::getExtractElement(V2, ++ ConstantInt::get(Ty, i)); ++ Constant *Cond = dyn_cast(CondV->getOperand(i)); ++ if (V1Element == V2Element) { ++ V = V1Element; ++ } ++ else if (isa(Cond)) { ++ V = isa(V1Element) ? V1Element : V2Element; ++ } ++ else { ++ if (!isa(Cond)) break; ++ V = Cond->isNullValue() ? V2Element : V1Element; ++ } ++ Result.push_back(V); + } + + // If we were able to build the vector, return it.