[llvm] 413a187 - [Inliner] Handle 'no-signed-zeros-fp-math' function attribute.

Akira Hatanaka via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 24 17:55:39 PDT 2020


Author: Michele Scandale
Date: 2020-06-24T17:53:59-07:00
New Revision: 413a187856a6dde568df38ab755e68a1c8dda04b

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

LOG: [Inliner] Handle 'no-signed-zeros-fp-math' function attribute.

All other floating point math optimization related attribute are merged
in a conservative way during function inlining. This commit adds the
merge rule for the 'no-signed-zeros-fp-math' attribute.

Differential Revision: https://reviews.llvm.org/D81714

Added: 
    

Modified: 
    llvm/include/llvm/IR/Attributes.td
    llvm/test/Transforms/Inline/attributes.ll

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/Attributes.td b/llvm/include/llvm/IR/Attributes.td
index ee48f40ca284..3516ce20e988 100644
--- a/llvm/include/llvm/IR/Attributes.td
+++ b/llvm/include/llvm/IR/Attributes.td
@@ -233,6 +233,7 @@ def ZExt : EnumAttr<"zeroext">;
 def LessPreciseFPMAD : StrBoolAttr<"less-precise-fpmad">;
 def NoInfsFPMath : StrBoolAttr<"no-infs-fp-math">;
 def NoNansFPMath : StrBoolAttr<"no-nans-fp-math">;
+def NoSignedZerosFPMath : StrBoolAttr<"no-signed-zeros-fp-math">;
 def UnsafeFPMath : StrBoolAttr<"unsafe-fp-math">;
 def NoJumpTables : StrBoolAttr<"no-jump-tables">;
 def NoInlineLineTables : StrBoolAttr<"no-inline-line-tables">;
@@ -270,6 +271,7 @@ class MergeRule<string F> {
 def : MergeRule<"setAND<LessPreciseFPMADAttr>">;
 def : MergeRule<"setAND<NoInfsFPMathAttr>">;
 def : MergeRule<"setAND<NoNansFPMathAttr>">;
+def : MergeRule<"setAND<NoSignedZerosFPMathAttr>">;
 def : MergeRule<"setAND<UnsafeFPMathAttr>">;
 def : MergeRule<"setOR<NoImplicitFloatAttr>">;
 def : MergeRule<"setOR<NoJumpTablesAttr>">;

diff  --git a/llvm/test/Transforms/Inline/attributes.ll b/llvm/test/Transforms/Inline/attributes.ll
index 5f27ac555129..07d1b36e485b 100644
--- a/llvm/test/Transforms/Inline/attributes.ll
+++ b/llvm/test/Transforms/Inline/attributes.ll
@@ -440,9 +440,177 @@ define i32 @test_null-pointer-is-valid2(i32 %i) null_pointer_is_valid {
 ; CHECK-NEXT: ret i32
 }
 
+define i32 @no-infs-fp-math_callee0(i32 %i) "no-infs-fp-math"="false" {
+  ret i32 %i
+; CHECK: @no-infs-fp-math_callee0(i32 %i) [[NO_INFS_FPMATH_FALSE:#[0-9]+]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @no-infs-fp-math_callee1(i32 %i) "no-infs-fp-math"="true" {
+  ret i32 %i
+; CHECK: @no-infs-fp-math_callee1(i32 %i) [[NO_INFS_FPMATH_TRUE:#[0-9]+]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @test_no-infs-fp-math0(i32 %i) "no-infs-fp-math"="false" {
+  %1 = call i32 @no-infs-fp-math_callee0(i32 %i)
+  ret i32 %1
+; CHECK: @test_no-infs-fp-math0(i32 %i) [[NO_INFS_FPMATH_FALSE]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @test_no-infs-fp-math1(i32 %i) "no-infs-fp-math"="false" {
+  %1 = call i32 @no-infs-fp-math_callee1(i32 %i)
+  ret i32 %1
+; CHECK: @test_no-infs-fp-math1(i32 %i) [[NO_INFS_FPMATH_FALSE]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @test_no-infs-fp-math2(i32 %i) "no-infs-fp-math"="true" {
+  %1 = call i32 @no-infs-fp-math_callee0(i32 %i)
+  ret i32 %1
+; CHECK: @test_no-infs-fp-math2(i32 %i) [[NO_INFS_FPMATH_FALSE]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @test_no-infs-fp-math3(i32 %i) "no-infs-fp-math"="true" {
+  %1 = call i32 @no-infs-fp-math_callee1(i32 %i)
+  ret i32 %1
+; CHECK: @test_no-infs-fp-math3(i32 %i) [[NO_INFS_FPMATH_TRUE]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @no-nans-fp-math_callee0(i32 %i) "no-nans-fp-math"="false" {
+  ret i32 %i
+; CHECK: @no-nans-fp-math_callee0(i32 %i) [[NO_NANS_FPMATH_FALSE:#[0-9]+]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @no-nans-fp-math_callee1(i32 %i) "no-nans-fp-math"="true" {
+  ret i32 %i
+; CHECK: @no-nans-fp-math_callee1(i32 %i) [[NO_NANS_FPMATH_TRUE:#[0-9]+]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @test_no-nans-fp-math0(i32 %i) "no-nans-fp-math"="false" {
+  %1 = call i32 @no-nans-fp-math_callee0(i32 %i)
+  ret i32 %1
+; CHECK: @test_no-nans-fp-math0(i32 %i) [[NO_NANS_FPMATH_FALSE]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @test_no-nans-fp-math1(i32 %i) "no-nans-fp-math"="false" {
+  %1 = call i32 @no-nans-fp-math_callee1(i32 %i)
+  ret i32 %1
+; CHECK: @test_no-nans-fp-math1(i32 %i) [[NO_NANS_FPMATH_FALSE]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @test_no-nans-fp-math2(i32 %i) "no-nans-fp-math"="true" {
+  %1 = call i32 @no-nans-fp-math_callee0(i32 %i)
+  ret i32 %1
+; CHECK: @test_no-nans-fp-math2(i32 %i) [[NO_NANS_FPMATH_FALSE]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @test_no-nans-fp-math3(i32 %i) "no-nans-fp-math"="true" {
+  %1 = call i32 @no-nans-fp-math_callee1(i32 %i)
+  ret i32 %1
+; CHECK: @test_no-nans-fp-math3(i32 %i) [[NO_NANS_FPMATH_TRUE]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @no-signed-zeros-fp-math_callee0(i32 %i) "no-signed-zeros-fp-math"="false" {
+  ret i32 %i
+; CHECK: @no-signed-zeros-fp-math_callee0(i32 %i) [[NO_SIGNED_ZEROS_FPMATH_FALSE:#[0-9]+]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @no-signed-zeros-fp-math_callee1(i32 %i) "no-signed-zeros-fp-math"="true" {
+  ret i32 %i
+; CHECK: @no-signed-zeros-fp-math_callee1(i32 %i) [[NO_SIGNED_ZEROS_FPMATH_TRUE:#[0-9]+]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @test_no-signed-zeros-fp-math0(i32 %i) "no-signed-zeros-fp-math"="false" {
+  %1 = call i32 @no-signed-zeros-fp-math_callee0(i32 %i)
+  ret i32 %1
+; CHECK: @test_no-signed-zeros-fp-math0(i32 %i) [[NO_SIGNED_ZEROS_FPMATH_FALSE]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @test_no-signed-zeros-fp-math1(i32 %i) "no-signed-zeros-fp-math"="false" {
+  %1 = call i32 @no-signed-zeros-fp-math_callee1(i32 %i)
+  ret i32 %1
+; CHECK: @test_no-signed-zeros-fp-math1(i32 %i) [[NO_SIGNED_ZEROS_FPMATH_FALSE]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @test_no-signed-zeros-fp-math2(i32 %i) "no-signed-zeros-fp-math"="true" {
+  %1 = call i32 @no-signed-zeros-fp-math_callee0(i32 %i)
+  ret i32 %1
+; CHECK: @test_no-signed-zeros-fp-math2(i32 %i) [[NO_SIGNED_ZEROS_FPMATH_FALSE]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @test_no-signed-zeros-fp-math3(i32 %i) "no-signed-zeros-fp-math"="true" {
+  %1 = call i32 @no-signed-zeros-fp-math_callee1(i32 %i)
+  ret i32 %1
+; CHECK: @test_no-signed-zeros-fp-math3(i32 %i) [[NO_SIGNED_ZEROS_FPMATH_TRUE]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @unsafe-fp-math_callee0(i32 %i) "unsafe-fp-math"="false" {
+  ret i32 %i
+; CHECK: @unsafe-fp-math_callee0(i32 %i) [[UNSAFE_FPMATH_FALSE:#[0-9]+]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @unsafe-fp-math_callee1(i32 %i) "unsafe-fp-math"="true" {
+  ret i32 %i
+; CHECK: @unsafe-fp-math_callee1(i32 %i) [[UNSAFE_FPMATH_TRUE:#[0-9]+]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @test_unsafe-fp-math0(i32 %i) "unsafe-fp-math"="false" {
+  %1 = call i32 @unsafe-fp-math_callee0(i32 %i)
+  ret i32 %1
+; CHECK: @test_unsafe-fp-math0(i32 %i) [[UNSAFE_FPMATH_FALSE]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @test_unsafe-fp-math1(i32 %i) "unsafe-fp-math"="false" {
+  %1 = call i32 @unsafe-fp-math_callee1(i32 %i)
+  ret i32 %1
+; CHECK: @test_unsafe-fp-math1(i32 %i) [[UNSAFE_FPMATH_FALSE]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @test_unsafe-fp-math2(i32 %i) "unsafe-fp-math"="true" {
+  %1 = call i32 @unsafe-fp-math_callee0(i32 %i)
+  ret i32 %1
+; CHECK: @test_unsafe-fp-math2(i32 %i) [[UNSAFE_FPMATH_FALSE]] {
+; CHECK-NEXT: ret i32
+}
+
+define i32 @test_unsafe-fp-math3(i32 %i) "unsafe-fp-math"="true" {
+  %1 = call i32 @unsafe-fp-math_callee1(i32 %i)
+  ret i32 %1
+; CHECK: @test_unsafe-fp-math3(i32 %i) [[UNSAFE_FPMATH_TRUE]] {
+; CHECK-NEXT: ret i32
+}
+
 ; CHECK: attributes [[SLH]] = { speculative_load_hardening }
 ; CHECK: attributes [[FPMAD_FALSE]] = { "less-precise-fpmad"="false" }
 ; CHECK: attributes [[FPMAD_TRUE]] = { "less-precise-fpmad"="true" }
 ; CHECK: attributes [[NOIMPLICITFLOAT]] = { noimplicitfloat }
 ; CHECK: attributes [[NOUSEJUMPTABLES]] = { "no-jump-tables"="true" }
 ; CHECK: attributes [[NULLPOINTERISVALID]] = { null_pointer_is_valid }
+; CHECK: attributes [[NO_INFS_FPMATH_FALSE]] = { "no-infs-fp-math"="false" }
+; CHECK: attributes [[NO_INFS_FPMATH_TRUE]] = { "no-infs-fp-math"="true" }
+; CHECK: attributes [[NO_NANS_FPMATH_FALSE]] = { "no-nans-fp-math"="false" }
+; CHECK: attributes [[NO_NANS_FPMATH_TRUE]] = { "no-nans-fp-math"="true" }
+; CHECK: attributes [[NO_SIGNED_ZEROS_FPMATH_FALSE]] = { "no-signed-zeros-fp-math"="false" }
+; CHECK: attributes [[NO_SIGNED_ZEROS_FPMATH_TRUE]] = { "no-signed-zeros-fp-math"="true" }
+; CHECK: attributes [[UNSAFE_FPMATH_FALSE]] = { "unsafe-fp-math"="false" }
+; CHECK: attributes [[UNSAFE_FPMATH_TRUE]] = { "unsafe-fp-math"="true" }


        


More information about the llvm-commits mailing list