Skip to content

Commit 76db09a

Browse files
committed
Address review comments and try to fix test
1 parent 0463ba3 commit 76db09a

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

stdlib/public/core/Builtin.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,10 @@ public func _onFastPath() {
290290
Builtin.onFastPath()
291291
}
292292

293-
@_transparent
294-
public func _assume(_ condition: Bool) {
293+
// Optimizier hint that the condition is true. The condition is unchecked.
294+
// The builtin acts as an opaque instruction with side-effects.
295+
@usableFromInline @_transparent
296+
func _uncheckedUnsafeAssume(_ condition: Bool) {
295297
_ = Builtin.assume_Int1(condition._value)
296298
}
297299

test/IRGen/assume.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
// LLVM uses the assume intrinsic to strength reduce the division.
44

5-
// CHECK-LABEL: define swiftcc i64 @"$s1A10testAssumeyS2iF"(i64)
6-
// CHECK: [[COND:%.*]] = icmp sgt i64 %0, -1
5+
// CHECK-LABEL: define{{.*}} swiftcc i{{(64|32)}} @"$s1A10testAssumeyS2iF"(i{{(64|32)}})
6+
// CHECK: [[COND:%.*]] = icmp sgt i{{(64|32)}} %0, -1
77
// CHECK: tail call void @llvm.assume(i1 [[COND]])
8-
// CHECK: [[RES:%.*]] = lshr i64 %0, 6
9-
// CHECK: ret i64 [[RES]]
8+
// CHECK: [[RES:%.*]] = lshr i{{(64|32)}} %0, 6
9+
// CHECK: ret i{{(64|32)}} [[RES]]
1010

1111
public func testAssume(_ i: Int) -> Int {
1212
let cond = i >= 0

0 commit comments

Comments
 (0)