@@ -186,6 +186,10 @@ def IntrSpeculatable : IntrinsicProperty;
186186// defined by the hasSideEffects property of the TableGen Instruction class.
187187def IntrHasSideEffects : IntrinsicProperty;
188188
189+ // Result will not be undef or poison if all arguments are not undef and not
190+ // poison.
191+ def IntrNoCreateUndefOrPoison : IntrinsicProperty;
192+
189193//===----------------------------------------------------------------------===//
190194// IIT constants and utils
191195//===----------------------------------------------------------------------===//
@@ -1039,7 +1043,7 @@ def int_experimental_memset_pattern
10391043// FIXME: Add version of these floating point intrinsics which allow non-default
10401044// rounding modes and FP exception handling.
10411045
1042- let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
1046+ let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrNoCreateUndefOrPoison ] in {
10431047 def int_fma : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
10441048 [LLVMMatchType<0>, LLVMMatchType<0>,
10451049 LLVMMatchType<0>]>;
@@ -1052,16 +1056,8 @@ let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
10521056 // environment so they can be treated as readnone.
10531057 def int_sqrt : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
10541058 def int_powi : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, llvm_anyint_ty]>;
1055- def int_asin : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1056- def int_acos : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1057- def int_atan : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1058- def int_atan2 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, LLVMMatchType<0>]>;
10591059 def int_sin : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
10601060 def int_cos : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1061- def int_tan : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1062- def int_sinh : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1063- def int_cosh : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1064- def int_tanh : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
10651061 def int_pow : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
10661062 [LLVMMatchType<0>, LLVMMatchType<0>]>;
10671063 def int_log : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
@@ -1080,12 +1076,6 @@ let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
10801076 def int_nearbyint : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
10811077 def int_round : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
10821078 def int_roundeven : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1083- def int_sincos : DefaultAttrsIntrinsic<[LLVMMatchType<0>, LLVMMatchType<0>],
1084- [llvm_anyfloat_ty]>;
1085- def int_sincospi : DefaultAttrsIntrinsic<[LLVMMatchType<0>, LLVMMatchType<0>],
1086- [llvm_anyfloat_ty]>;
1087- def int_modf : DefaultAttrsIntrinsic<[LLVMMatchType<0>, LLVMMatchType<0>],
1088- [llvm_anyfloat_ty]>;
10891079
10901080 // Truncate a floating point number with a specific rounding mode
10911081 def int_fptrunc_round : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
@@ -1097,6 +1087,8 @@ let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
10971087 def int_arithmetic_fence : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>],
10981088 [IntrNoMem]>;
10991089
1090+ // If the value doesn't fit an unspecified value is returned, but this
1091+ // is not poison so we can still mark these as IntrNoCreateUndefOrPoison.
11001092 def int_lround : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
11011093 def int_llround : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
11021094 def int_lrint : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
@@ -1110,29 +1102,50 @@ let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
11101102 def int_frexp : DefaultAttrsIntrinsic<[llvm_anyfloat_ty, llvm_anyint_ty], [LLVMMatchType<0>]>;
11111103}
11121104
1105+ // TODO: Move all of these into the IntrNoCreateUndefOrPoison case above.
1106+ let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
1107+ // These functions do not read memory, but are sensitive to the
1108+ // rounding mode. LLVM purposely does not model changes to the FP
1109+ // environment so they can be treated as readnone.
1110+ def int_asin : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1111+ def int_acos : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1112+ def int_atan : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1113+ def int_atan2 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, LLVMMatchType<0>]>;
1114+ def int_tan : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1115+ def int_sinh : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1116+ def int_cosh : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1117+ def int_tanh : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1118+ def int_sincos : DefaultAttrsIntrinsic<[LLVMMatchType<0>, LLVMMatchType<0>],
1119+ [llvm_anyfloat_ty]>;
1120+ def int_sincospi : DefaultAttrsIntrinsic<[LLVMMatchType<0>, LLVMMatchType<0>],
1121+ [llvm_anyfloat_ty]>;
1122+ def int_modf : DefaultAttrsIntrinsic<[LLVMMatchType<0>, LLVMMatchType<0>],
1123+ [llvm_anyfloat_ty]>;
1124+ }
1125+
11131126def int_minnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
11141127 [LLVMMatchType<0>, LLVMMatchType<0>],
1115- [IntrNoMem, IntrSpeculatable, Commutative]
1128+ [IntrNoMem, IntrSpeculatable, Commutative, IntrNoCreateUndefOrPoison ]
11161129>;
11171130def int_maxnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
11181131 [LLVMMatchType<0>, LLVMMatchType<0>],
1119- [IntrNoMem, IntrSpeculatable, Commutative]
1132+ [IntrNoMem, IntrSpeculatable, Commutative, IntrNoCreateUndefOrPoison ]
11201133>;
11211134def int_minimum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
11221135 [LLVMMatchType<0>, LLVMMatchType<0>],
1123- [IntrNoMem, IntrSpeculatable, Commutative]
1136+ [IntrNoMem, IntrSpeculatable, Commutative, IntrNoCreateUndefOrPoison ]
11241137>;
11251138def int_maximum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
11261139 [LLVMMatchType<0>, LLVMMatchType<0>],
1127- [IntrNoMem, IntrSpeculatable, Commutative]
1140+ [IntrNoMem, IntrSpeculatable, Commutative, IntrNoCreateUndefOrPoison ]
11281141>;
11291142def int_minimumnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
11301143 [LLVMMatchType<0>, LLVMMatchType<0>],
1131- [IntrNoMem, IntrSpeculatable, Commutative]
1144+ [IntrNoMem, IntrSpeculatable, Commutative, IntrNoCreateUndefOrPoison ]
11321145>;
11331146def int_maximumnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
11341147 [LLVMMatchType<0>, LLVMMatchType<0>],
1135- [IntrNoMem, IntrSpeculatable, Commutative]
1148+ [IntrNoMem, IntrSpeculatable, Commutative, IntrNoCreateUndefOrPoison ]
11361149>;
11371150
11381151// Internal interface for object size checking
@@ -1164,7 +1177,7 @@ let IntrProperties = [IntrInaccessibleMemOnly] in {
11641177def int_is_fpclass
11651178 : DefaultAttrsIntrinsic<[LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
11661179 [llvm_anyfloat_ty, llvm_i32_ty],
1167- [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>]>;
1180+ [IntrNoMem, IntrSpeculatable, IntrNoCreateUndefOrPoison, ImmArg<ArgIndex<1>>]>;
11681181
11691182//===--------------- Constrained Floating Point Intrinsics ----------------===//
11701183//
@@ -1406,7 +1419,7 @@ def int_expect_with_probability : DefaultAttrsIntrinsic<[llvm_anyint_ty],
14061419//
14071420
14081421// None of these intrinsics accesses memory at all.
1409- let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
1422+ let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrNoCreateUndefOrPoison ] in {
14101423 def int_bswap: DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
14111424 def int_ctpop: DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
14121425 def int_bitreverse : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
@@ -1521,7 +1534,7 @@ def int_adjust_trampoline : DefaultAttrsIntrinsic<
15211534//
15221535
15231536// Expose the carry flag from add operations on two integrals.
1524- let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
1537+ let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrNoCreateUndefOrPoison ] in {
15251538 def int_sadd_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
15261539 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
15271540 [LLVMMatchType<0>, LLVMMatchType<0>]>;
@@ -1547,16 +1560,16 @@ let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
15471560//
15481561def int_sadd_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
15491562 [LLVMMatchType<0>, LLVMMatchType<0>],
1550- [IntrNoMem, IntrSpeculatable, Commutative]>;
1563+ [IntrNoMem, IntrSpeculatable, IntrNoCreateUndefOrPoison, Commutative]>;
15511564def int_uadd_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
15521565 [LLVMMatchType<0>, LLVMMatchType<0>],
1553- [IntrNoMem, IntrSpeculatable, Commutative]>;
1566+ [IntrNoMem, IntrSpeculatable, IntrNoCreateUndefOrPoison, Commutative]>;
15541567def int_ssub_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
15551568 [LLVMMatchType<0>, LLVMMatchType<0>],
1556- [IntrNoMem, IntrSpeculatable]>;
1569+ [IntrNoMem, IntrSpeculatable, IntrNoCreateUndefOrPoison ]>;
15571570def int_usub_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
15581571 [LLVMMatchType<0>, LLVMMatchType<0>],
1559- [IntrNoMem, IntrSpeculatable]>;
1572+ [IntrNoMem, IntrSpeculatable, IntrNoCreateUndefOrPoison ]>;
15601573def int_sshl_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
15611574 [LLVMMatchType<0>, LLVMMatchType<0>],
15621575 [IntrNoMem, IntrSpeculatable]>;
@@ -1611,22 +1624,22 @@ def int_abs : DefaultAttrsIntrinsic<
16111624
16121625def int_smax : DefaultAttrsIntrinsic<
16131626 [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
1614- [IntrNoMem, IntrSpeculatable]>;
1627+ [IntrNoMem, IntrSpeculatable, IntrNoCreateUndefOrPoison ]>;
16151628def int_smin : DefaultAttrsIntrinsic<
16161629 [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
1617- [IntrNoMem, IntrSpeculatable]>;
1630+ [IntrNoMem, IntrSpeculatable, IntrNoCreateUndefOrPoison ]>;
16181631def int_umax : DefaultAttrsIntrinsic<
16191632 [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
1620- [IntrNoMem, IntrSpeculatable]>;
1633+ [IntrNoMem, IntrSpeculatable, IntrNoCreateUndefOrPoison ]>;
16211634def int_umin : DefaultAttrsIntrinsic<
16221635 [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
1623- [IntrNoMem, IntrSpeculatable]>;
1636+ [IntrNoMem, IntrSpeculatable, IntrNoCreateUndefOrPoison ]>;
16241637def int_scmp : DefaultAttrsIntrinsic<
16251638 [llvm_anyint_ty], [llvm_anyint_ty, LLVMMatchType<1>],
1626- [IntrNoMem, IntrSpeculatable, Range<RetIndex, -1, 2>]>;
1639+ [IntrNoMem, IntrSpeculatable, IntrNoCreateUndefOrPoison, Range<RetIndex, -1, 2>]>;
16271640def int_ucmp : DefaultAttrsIntrinsic<
16281641 [llvm_anyint_ty], [llvm_anyint_ty, LLVMMatchType<1>],
1629- [IntrNoMem, IntrSpeculatable, Range<RetIndex, -1, 2>]>;
1642+ [IntrNoMem, IntrSpeculatable, IntrNoCreateUndefOrPoison, Range<RetIndex, -1, 2>]>;
16301643
16311644//===------------------------- Memory Use Markers -------------------------===//
16321645//
@@ -1868,7 +1881,7 @@ def int_convert_from_fp16 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [llvm_i16_
18681881}
18691882
18701883// Saturating floating point to integer intrinsics
1871- let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
1884+ let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrNoCreateUndefOrPoison ] in {
18721885def int_fptoui_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
18731886def int_fptosi_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
18741887}
@@ -1890,7 +1903,7 @@ def int_fake_use : DefaultAttrsIntrinsic<[], [llvm_vararg_ty],
18901903// First argument must be pointer or vector of pointer. This is checked by the
18911904// verifier.
18921905def int_ptrmask: DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchType<0>, llvm_anyint_ty],
1893- [IntrNoMem, IntrSpeculatable]>;
1906+ [IntrNoMem, IntrSpeculatable, IntrNoCreateUndefOrPoison ]>;
18941907
18951908// Intrinsic to wrap a thread local variable.
18961909def int_threadlocal_address : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [LLVMMatchType<0>],
0 commit comments