Skip to content

Commit 54e7cc9

Browse files
committed
Merge trill/master into master
2 parents 5d35298 + 5705c30 commit 54e7cc9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Sources/LLVM/IRBuilder.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,8 @@ public class IRBuilder {
654654
/// Build an integer comparison between the two provided values using the
655655
/// given predicate.
656656
///
657-
/// Attempting to compare operands that are not integers is a fatal condition.
657+
/// - precondition: Arguments must be integer or pointer or integer vector typed
658+
/// - precondition: lhs.type == rhs.type
658659
///
659660
/// - parameter lhs: The first value to compare.
660661
/// - parameter rhs: The second value to compare.
@@ -668,9 +669,13 @@ public class IRBuilder {
668669
name: String = "") -> IRValue {
669670
let lhsVal = lhs.asLLVM()
670671
let rhsVal = rhs.asLLVM()
671-
guard lhs.type is IntType else {
672-
fatalError("Can only build ICMP instruction with int types")
673-
}
672+
assert(
673+
(lhs.type is IntType && rhs.type is IntType) ||
674+
(lhs.type is PointerType && rhs.type is PointerType) ||
675+
((lhs.type is VectorType && rhs.type is VectorType) &&
676+
(LLVMGetTypeKind(LLVMGetElementType(lhs.type.asLLVM())) == LLVMIntegerTypeKind) &&
677+
(LLVMGetTypeKind(LLVMGetElementType(rhs.type.asLLVM())) == LLVMIntegerTypeKind)),
678+
"Can only build ICMP instruction with int or pointer types")
674679
return LLVMBuildICmp(llvm, predicate.llvm, lhsVal, rhsVal, name)
675680
}
676681

0 commit comments

Comments
 (0)