Skip to content

Commit f76e411

Browse files
committed
[InstCombine] Add fast-path for C == 1.
1 parent a509f2f commit f76e411

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5123,10 +5123,13 @@ static Instruction *foldICmpXorXX(ICmpInst &I, const SimplifyQuery &Q,
51235123
/// Return true if X is a multiple of C.
51245124
/// TODO: Handle non-power-of-2 factors.
51255125
static bool isMultipleOf(Value *X, const APInt &C, const SimplifyQuery &Q) {
5126+
if (C.isOne())
5127+
return true;
5128+
51265129
if (!C.isPowerOf2())
51275130
return false;
51285131

5129-
return C.isOne() || MaskedValueIsZero(X, C - 1, Q);
5132+
return MaskedValueIsZero(X, C - 1, Q);
51305133
}
51315134

51325135
/// Try to fold icmp (binop), X or icmp X, (binop).

0 commit comments

Comments
 (0)