mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-27 15:41:46 +00:00
[LV] Shrink operands before creating new instr to force eval order.
Shrink operands before creating the new instruction to make sure the same evaluation order is used on all platforms. This fixes buildbot failures due to different argument evaluation order on different systems.
This commit is contained in:
parent
7bd481d9af
commit
822c749aec
@ -3595,21 +3595,22 @@ void InnerLoopVectorizer::truncateToMinimalBitwidths(VPTransformState &State) {
|
||||
// unfortunately.
|
||||
Value *NewI = nullptr;
|
||||
if (auto *BO = dyn_cast<BinaryOperator>(I)) {
|
||||
NewI = B.CreateBinOp(BO->getOpcode(), ShrinkOperand(BO->getOperand(0)),
|
||||
ShrinkOperand(BO->getOperand(1)));
|
||||
Value *Op0 = ShrinkOperand(BO->getOperand(0));
|
||||
Value *Op1 = ShrinkOperand(BO->getOperand(1));
|
||||
NewI = B.CreateBinOp(BO->getOpcode(), Op0, Op1);
|
||||
|
||||
// Any wrapping introduced by shrinking this operation shouldn't be
|
||||
// considered undefined behavior. So, we can't unconditionally copy
|
||||
// arithmetic wrapping flags to NewI.
|
||||
cast<BinaryOperator>(NewI)->copyIRFlags(I, /*IncludeWrapFlags=*/false);
|
||||
} else if (auto *CI = dyn_cast<ICmpInst>(I)) {
|
||||
NewI =
|
||||
B.CreateICmp(CI->getPredicate(), ShrinkOperand(CI->getOperand(0)),
|
||||
ShrinkOperand(CI->getOperand(1)));
|
||||
Value *Op0 = ShrinkOperand(BO->getOperand(0));
|
||||
Value *Op1 = ShrinkOperand(BO->getOperand(1));
|
||||
NewI = B.CreateICmp(CI->getPredicate(), Op0, Op1);
|
||||
} else if (auto *SI = dyn_cast<SelectInst>(I)) {
|
||||
NewI = B.CreateSelect(SI->getCondition(),
|
||||
ShrinkOperand(SI->getTrueValue()),
|
||||
ShrinkOperand(SI->getFalseValue()));
|
||||
Value *TV = ShrinkOperand(SI->getTrueValue());
|
||||
Value *FV = ShrinkOperand(SI->getFalseValue());
|
||||
NewI = B.CreateSelect(SI->getCondition(), TV, FV);
|
||||
} else if (auto *CI = dyn_cast<CastInst>(I)) {
|
||||
switch (CI->getOpcode()) {
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user