[llvm] b9ac390 - [GISel] Add generic implementation for @llvm.expect.with.probability when optimizations are disabled (#117835)

via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 29 19:30:16 PST 2024


Author: antangelo
Date: 2024-11-29T22:30:13-05:00
New Revision: b9ac390cc7ec208fc738a91540b070f499b292b8

URL: https://github.com/llvm/llvm-project/commit/b9ac390cc7ec208fc738a91540b070f499b292b8
DIFF: https://github.com/llvm/llvm-project/commit/b9ac390cc7ec208fc738a91540b070f499b292b8.diff

LOG: [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

Added: 
    

Modified: 
    llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
    llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-no-op-intrinsics.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 675f55d8086bc3..f668e41094bbc8 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -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:

diff  --git a/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-no-op-intrinsics.ll b/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-no-op-intrinsics.ll
index 88828950353a7e..4ab347c37f0d7a 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-no-op-intrinsics.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-no-op-intrinsics.ll
@@ -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


        


More information about the llvm-commits mailing list