@@ -2051,27 +2051,6 @@ Instruction *InstCombinerImpl::foldSelectInstWithICmp(SelectInst &SI,
20512051 return Changed ? &SI : nullptr ;
20522052}
20532053
2054- // / We have an SPF (e.g. a min or max) of an SPF of the form:
2055- // / SPF2(SPF1(A, B), C)
2056- Instruction *InstCombinerImpl::foldSPFofSPF (Instruction *Inner,
2057- SelectPatternFlavor SPF1, Value *A,
2058- Value *B, Instruction &Outer,
2059- SelectPatternFlavor SPF2,
2060- Value *C) {
2061- if (Outer.getType () != Inner->getType ())
2062- return nullptr ;
2063-
2064- if (C == A || C == B) {
2065- // MAX(MAX(A, B), B) -> MAX(A, B)
2066- // MIN(MIN(a, b), a) -> MIN(a, b)
2067- // TODO: This could be done in instsimplify.
2068- if (SPF1 == SPF2 && SelectPatternResult::isMinOrMax (SPF1))
2069- return replaceInstUsesWith (Outer, Inner);
2070- }
2071-
2072- return nullptr ;
2073- }
2074-
20752054// / Turn select C, (X + Y), (X - Y) --> (X + (select C, Y, (-Y))).
20762055// / This is even legal for FP.
20772056static Instruction *foldAddSubSelect (SelectInst &SI,
@@ -4157,17 +4136,6 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
41574136 Instruction::CastOps CastOp;
41584137 SelectPatternResult SPR = matchSelectPattern (&SI, LHS, RHS, &CastOp);
41594138 auto SPF = SPR.Flavor ;
4160- if (SPF) {
4161- Value *LHS2, *RHS2;
4162- if (SelectPatternFlavor SPF2 = matchSelectPattern (LHS, LHS2, RHS2).Flavor )
4163- if (Instruction *R = foldSPFofSPF (cast<Instruction>(LHS), SPF2, LHS2,
4164- RHS2, SI, SPF, RHS))
4165- return R;
4166- if (SelectPatternFlavor SPF2 = matchSelectPattern (RHS, LHS2, RHS2).Flavor )
4167- if (Instruction *R = foldSPFofSPF (cast<Instruction>(RHS), SPF2, LHS2,
4168- RHS2, SI, SPF, LHS))
4169- return R;
4170- }
41714139
41724140 if (SelectPatternResult::isMinOrMax (SPF)) {
41734141 // Canonicalize so that
0 commit comments