Skip to content

Commit

Permalink
[GISel] Add generic implementation for @llvm.expect.with.probability …
Browse files Browse the repository at this point in the history
…when optimizations are disabled (llvm#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 llvm#115411 for GlobalISel
  • Loading branch information
antangelo authored Nov 30, 2024
1 parent ee19eb3 commit b9ac390
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2431,6 +2431,7 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID,
case Intrinsic::invariant_end:
return true;
case Intrinsic::expect:
case Intrinsic::expect_with_probability:
case Intrinsic::annotation:
case Intrinsic::ptr_annotation:
case Intrinsic::launder_invariant_group:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ define i64 @expect_with_probability_i64(i64 %arg0) {
; CHECK-NEXT: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
; CHECK-NEXT: [[INT:%[0-9]+]]:_(s64) = G_INTRINSIC intrinsic(@llvm.expect.with.probability), [[COPY]](s64), [[C]](s64), double 5.000000e-01
; CHECK-NEXT: $x0 = COPY [[INT]](s64)
; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY [[COPY]](s64)
; CHECK-NEXT: $x0 = COPY [[COPY1]](s64)
; CHECK-NEXT: RET_ReallyLR implicit $x0
%expval = call i64 @llvm.expect.with.probability.i64(i64 %arg0, i64 1, double 0.5)
ret i64 %expval
Expand Down

0 comments on commit b9ac390

Please sign in to comment.