Skip to content

Commit 84e2d19

Browse files
committed
Fix issues
1 parent c1152ff commit 84e2d19

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,8 +1154,6 @@ static Value *foldAbsDiff(ICmpInst *Cmp, Value *TVal, Value *FVal,
11541154
}
11551155

11561156
// Match: (A > B) ? (A - B) : (0 - (A - B)) --> abs(A - B)
1157-
// Also handles commuted cases like (B < A), (A >= B), (B <= A) after
1158-
// normalization
11591157
if (Pred == CmpInst::ICMP_SGT &&
11601158
match(TI, m_NSWSub(m_Specific(A), m_Specific(B))) &&
11611159
match(FI, m_Neg(m_Specific(TI)))) {
@@ -1164,27 +1162,22 @@ static Value *foldAbsDiff(ICmpInst *Cmp, Value *TVal, Value *FVal,
11641162
}
11651163

11661164
// Match: (A < B) ? (0 - (A - B)) : (A - B) --> abs(A - B)
1167-
// This handles cases like (A <= B) after normalization
11681165
if (Pred == CmpInst::ICMP_SLT &&
1169-
match(TI, m_Neg(m_NSWSub(m_Specific(A), m_Specific(B)))) &&
1170-
match(FI, m_NSWSub(m_Specific(A), m_Specific(B)))) {
1166+
match(FI, m_NSWSub(m_Specific(A), m_Specific(B))) &&
1167+
match(TI, m_Neg(m_Specific(FI)))) {
11711168
return Builder.CreateBinaryIntrinsic(Intrinsic::abs, FI,
11721169
Builder.getFalse());
11731170
}
11741171

11751172
// Match: (A > B) ? (0 - (B - A)) : (B - A) --> abs(B - A)
1176-
// This handles cases like (B <= A) after normalization where the subtraction
1177-
// operands are swapped
11781173
if (Pred == CmpInst::ICMP_SGT &&
1179-
match(TI, m_Neg(m_NSWSub(m_Specific(B), m_Specific(A)))) &&
1180-
match(FI, m_NSWSub(m_Specific(B), m_Specific(A)))) {
1174+
match(FI, m_NSWSub(m_Specific(B), m_Specific(A))) &&
1175+
match(TI, m_Neg(m_Specific(FI)))) {
11811176
return Builder.CreateBinaryIntrinsic(Intrinsic::abs, FI,
11821177
Builder.getFalse());
11831178
}
11841179

11851180
// Match: (A < B) ? (B - A) : (0 - (B - A)) --> abs(B - A)
1186-
// This handles cases where comparison operands are swapped relative to
1187-
// subtraction
11881181
if (Pred == CmpInst::ICMP_SLT &&
11891182
match(TI, m_NSWSub(m_Specific(B), m_Specific(A))) &&
11901183
match(FI, m_Neg(m_Specific(TI)))) {

0 commit comments

Comments
 (0)