diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -25476,14 +25476,16 @@ Syntax: """"""" -This is an overloaded intrinsic. You can use ``llvm.expect`` on any -integer bit width. +This is an overloaded intrinsic. You can use ``llvm.expect`` on any scalar or +vector integer type. :: declare i1 @llvm.expect.i1(i1 , i1 ) declare i32 @llvm.expect.i32(i32 , i32 ) declare i64 @llvm.expect.i64(i64 , i64 ) + declare <4 x i64> @llvm.expect.v4i64(<4 x i64> , <4 x i64> ) + declare @llvm.expect.nxv1i8( , ) Overview: """"""""" @@ -25509,19 +25511,22 @@ """"""" This intrinsic is similar to ``llvm.expect``. This is an overloaded intrinsic. -You can use ``llvm.expect.with.probability`` on any integer bit width. +You can use ``llvm.expect.with.probability`` on any scalar or vector integer +type. :: declare i1 @llvm.expect.with.probability.i1(i1 , i1 , double ) declare i32 @llvm.expect.with.probability.i32(i32 , i32 , double ) declare i64 @llvm.expect.with.probability.i64(i64 , i64 , double ) + declare <2 x i8> @llvm.expect.with.probability.v2i8(<2 x i8> , <2 x i8> , double ) + declare @llvm.expect.with.probability.nxv1i1( , , double ) Overview: """"""""" The ``llvm.expect.with.probability`` intrinsic provides information about -expected value of ``val`` with probability(or confidence) ``prob``, which can +expected value of ``val`` with probability (or confidence) ``prob``, which can be used by optimizers. Arguments: diff --git a/llvm/test/Transforms/LowerExpectIntrinsic/basic.ll b/llvm/test/Transforms/LowerExpectIntrinsic/basic.ll --- a/llvm/test/Transforms/LowerExpectIntrinsic/basic.ll +++ b/llvm/test/Transforms/LowerExpectIntrinsic/basic.ll @@ -281,6 +281,31 @@ ret i32 %t9 } +; CHECK-LABEL: @test11( +define <4 x i32> @test11(<4 x i64> %x, <4 x i32> %tval, <4 x i32> %fval) { + %expval = call <4 x i64> @llvm.expect.v4i64(<4 x i64> %x, <4 x i64> zeroinitializer) + %cmp = icmp ne <4 x i64> %expval, zeroinitializer + %sel = select <4 x i1> %cmp, <4 x i32> %tval, <4 x i32> %fval +; CHECK-NOT: @llvm.expect +; FIXME: We don't add branch weights to vector values +; CHECK: select{{.*}} + ret <4 x i32> %sel +} + +declare <4 x i64> @llvm.expect.v4i64(<4 x i64>, <4 x i64>) nounwind readnone + +; CHECK-LABEL: @test12( +define @test12( %x, %tval, %fval) { + %expval = call @llvm.expect.nxv1i64( %x, zeroinitializer) + %cmp = icmp ne %expval, zeroinitializer + %sel = select %cmp, %tval, %fval +; CHECK-NOT: @llvm.expect +; FIXME: We don't add branch weights to vector values +; CHECK: select{{.*}} + ret %sel +} + +declare @llvm.expect.nxv1i64(, ) nounwind readnone declare i1 @llvm.expect.i1(i1, i1) nounwind readnone diff --git a/llvm/test/Transforms/LowerExpectIntrinsic/expect-with-probability.ll b/llvm/test/Transforms/LowerExpectIntrinsic/expect-with-probability.ll --- a/llvm/test/Transforms/LowerExpectIntrinsic/expect-with-probability.ll +++ b/llvm/test/Transforms/LowerExpectIntrinsic/expect-with-probability.ll @@ -281,6 +281,29 @@ ret i32 %t9 } +; CHECK-LABEL: @test11( +define <2 x i8> @test11(<2 x i8> %x) { + %expval = call <2 x i8> @llvm.expect.with.probability.v2i8(<2 x i8> %x, <2 x i8> zeroinitializer, double 8.000000e-01) + %cmp = icmp ne <2 x i8> %expval, zeroinitializer + %sel = select <2 x i1> %cmp, <2 x i8> , <2 x i8> +; FIXME: We don't add branch weights to vector values +; CHECK: select{{.*}} + ret <2 x i8> %sel +} + +declare <2 x i8> @llvm.expect.with.probability.v2i8(<2 x i8>, <2 x i8>, double) nounwind readnone + +; CHECK-LABEL: @test12( +define @test12( %x, %tval, %fval) { + %expval = call @llvm.expect.with.probability.nxv2i8( %x, zeroinitializer, double 8.000000e-01) + %cmp = icmp ne %expval, zeroinitializer + %sel = select %cmp, %tval, %fval +; FIXME: We don't add branch weights to vector values +; CHECK: select{{.*}} + ret %sel +} + +declare @llvm.expect.with.probability.nxv2i8(, , double) nounwind readnone declare i1 @llvm.expect.with.probability.i1(i1, i1, double) nounwind readnone