Skip to content

Commit b9ac390

Browse files
authored
[GISel] Add generic implementation for @llvm.expect.with.probability when optimizations are disabled (#117835)
Handle @llvm.expect.with.probability in GlobalISel in the same way @llvm.expect is handled, passing the value through as-is. This can be encountered if the intrinsic is used without optimizations, which would otherwise transform it out. Fixes #115411 for GlobalISel
1 parent ee19eb3 commit b9ac390

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,6 +2431,7 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID,
24312431
case Intrinsic::invariant_end:
24322432
return true;
24332433
case Intrinsic::expect:
2434+
case Intrinsic::expect_with_probability:
24342435
case Intrinsic::annotation:
24352436
case Intrinsic::ptr_annotation:
24362437
case Intrinsic::launder_invariant_group:

llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-no-op-intrinsics.ll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ define i64 @expect_with_probability_i64(i64 %arg0) {
2020
; CHECK-NEXT: liveins: $x0
2121
; CHECK-NEXT: {{ $}}
2222
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
23-
; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
24-
; CHECK-NEXT: [[INT:%[0-9]+]]:_(s64) = G_INTRINSIC intrinsic(@llvm.expect.with.probability), [[COPY]](s64), [[C]](s64), double 5.000000e-01
25-
; CHECK-NEXT: $x0 = COPY [[INT]](s64)
23+
; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY [[COPY]](s64)
24+
; CHECK-NEXT: $x0 = COPY [[COPY1]](s64)
2625
; CHECK-NEXT: RET_ReallyLR implicit $x0
2726
%expval = call i64 @llvm.expect.with.probability.i64(i64 %arg0, i64 1, double 0.5)
2827
ret i64 %expval

0 commit comments

Comments
 (0)