[SimplifyCFG] Make range reduction code deterministic.
This generated IR based on the order of evaluation, which is different between GCC and Clang. With that in mind you get bootstrap miscompares if you compare a Clang built with GCC-built Clang vs. Clang built with Clang-built Clang. Diagnosing that made my head hurt. This also reverts commit r277337, which "fixed" the test case. llvm-svn: 277820
This commit is contained in:
@@ -5128,8 +5128,9 @@ static bool ReduceSwitchRange(SwitchInst *SI, IRBuilder<> &Builder,
|
||||
Builder.SetInsertPoint(SI);
|
||||
auto *ShiftC = ConstantInt::get(Ty, Shift);
|
||||
auto *Sub = Builder.CreateSub(SI->getCondition(), ConstantInt::get(Ty, Base));
|
||||
auto *Rot = Builder.CreateOr(Builder.CreateLShr(Sub, ShiftC),
|
||||
Builder.CreateShl(Sub, Ty->getBitWidth() - Shift));
|
||||
auto *LShr = Builder.CreateLShr(Sub, ShiftC);
|
||||
auto *Shl = Builder.CreateShl(Sub, Ty->getBitWidth() - Shift);
|
||||
auto *Rot = Builder.CreateOr(LShr, Shl);
|
||||
SI->replaceUsesOfWith(SI->getCondition(), Rot);
|
||||
|
||||
for (SwitchInst::CaseIt C = SI->case_begin(), E = SI->case_end(); C != E;
|
||||
|
||||
Reference in New Issue
Block a user