llvm.org GIT mirror llvm / 8b6d60f
Change math intrinsic attributes from readonly to readnone. These are operations that do not access memory but may be sensitive to floating-point environment changes. LLVM does not attempt to model FP environment changes, so this was unnecessarily conservative and was getting on the way of some optimizations, in particular SLP vectorization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203037 91177308-0d34-0410-b5e6-96231b3b80d8 Raul E. Silvera 6 years ago
4 changed file(s) with 17 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
284284 llvm_i32_ty, llvm_i1_ty],
285285 [IntrReadWriteArgMem, NoCapture<0>]>;
286286
287 // These functions do not actually read memory, but they are sensitive to the
288 // rounding mode. This needs to be modelled separately; in the meantime
289 // declaring them as reading memory is conservatively correct.
290 let Properties = [IntrReadMem] in {
287 let Properties = [IntrNoMem] in {
288 def int_fma : Intrinsic<[llvm_anyfloat_ty],
289 [LLVMMatchType<0>, LLVMMatchType<0>,
290 LLVMMatchType<0>]>;
291 def int_fmuladd : Intrinsic<[llvm_anyfloat_ty],
292 [LLVMMatchType<0>, LLVMMatchType<0>,
293 LLVMMatchType<0>]>;
294
295 // These functions do not read memory, but are sensitive to the
296 // rounding mode. LLVM purposely does not model changes to the FP
297 // environment so they can be treated as readnone.
291298 def int_sqrt : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
292299 def int_powi : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, llvm_i32_ty]>;
293300 def int_sin : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
308315 def int_rint : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
309316 def int_nearbyint : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
310317 def int_round : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
311 }
312
313 let Properties = [IntrNoMem] in {
314 def int_fma : Intrinsic<[llvm_anyfloat_ty],
315 [LLVMMatchType<0>, LLVMMatchType<0>,
316 LLVMMatchType<0>]>;
317
318 def int_fmuladd : Intrinsic<[llvm_anyfloat_ty],
319 [LLVMMatchType<0>, LLVMMatchType<0>,
320 LLVMMatchType<0>]>;
321318 }
322319
323320 // NOTE: these are internal interfaces.
6060 ; FIXME: test ALL the intrinsics in this file.
6161
6262 ; rdar://11542750
63 ; CHECK: declare void @llvm.trap() #2
63 ; CHECK: declare void @llvm.trap() #1
6464 declare void @llvm.trap()
6565
6666 define void @trap() {
6969 }
7070
7171 ; CHECK: attributes #0 = { nounwind readnone }
72 ; CHECK: attributes #1 = { nounwind readonly }
73 ; CHECK: attributes #2 = { noreturn nounwind }
72 ; CHECK: attributes #1 = { noreturn nounwind }
125125
126126 ; CHECK: declare <2 x double> @llvm.fma.v2f64(<2 x double>, <2 x double>, <2 x double>) #0
127127 ; CHECK: declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #0
128 ; CHECK: declare <2 x double> @llvm.cos.v2f64(<2 x double>) #1
129 ; CHECK: declare <2 x double> @llvm.powi.v2f64(<2 x double>, i32) #1
128 ; CHECK: declare <2 x double> @llvm.cos.v2f64(<2 x double>) #0
129 ; CHECK: declare <2 x double> @llvm.powi.v2f64(<2 x double>, i32) #0
130130
131131 ; CHECK: attributes #0 = { nounwind readnone }
132 ; CHECK: attributes #1 = { nounwind readonly }
159159 define double @test_simplify17(double %x) {
160160 ; CHECK-LABEL: @test_simplify17(
161161 %retval = call double @llvm.pow.f64(double %x, double 0.5)
162 ; CHECK-NEXT: [[SQRT:%[a-z0-9]+]] = call double @sqrt(double %x) [[NUW_RO]]
163 ; CHECK-NEXT: [[FABS:%[a-z0-9]+]] = call double @fabs(double [[SQRT]]) [[NUW_RO]]
162 ; CHECK-NEXT: [[SQRT:%[a-z0-9]+]] = call double @sqrt(double %x)
163 ; CHECK-NEXT: [[FABS:%[a-z0-9]+]] = call double @fabs(double [[SQRT]])
164164 ; CHECK-NEXT: [[FCMP:%[a-z0-9]+]] = fcmp oeq double %x, 0xFFF0000000000000
165165 ; CHECK-NEXT: [[SELECT:%[a-z0-9]+]] = select i1 [[FCMP]], double 0x7FF0000000000000, double [[FABS]]
166166 ret double %retval