[clang] [llvm] [mlir] IR: Promote "denormal-fp-math" to a first class attribute (PR #174293)
Mikael Holmen via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 6 02:00:55 PST 2026
mikaelholmen wrote:
> I get
>
> ```
> denormal_fpenv attribute may not apply to call sites
> %sqrtf = tail call float @sqrtf(float noundef -1.000000e+00) #1
> in function foo
> fatal error: error in backend: Broken function found, compilation aborted!
> ```
Instcombine seem to convert
```
; ModuleID = 'bbi-114859.c'
source_filename = "bbi-114859.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nounwind denormal_fpenv(float: preservesign)
define dso_local void @foo() local_unnamed_addr #0 {
entry:
%call = call double @sqrt(double noundef -1.000000e+00) #2, !tbaa !2
ret void
}
; Function Attrs: mustprogress nocallback nofree nounwind willreturn denormal_fpenv(float: preservesign) memory(errnomem: write)
declare double @sqrt(double noundef) local_unnamed_addr #1
attributes #0 = { nounwind denormal_fpenv(float: preservesign) "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn denormal_fpenv(float: preservesign) memory(errnomem: write) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
attributes #2 = { nounwind }
!llvm.module.flags = !{!0}
!llvm.ident = !{!1}
!llvm.errno.tbaa = !{!2}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 23.0.0git"}
!2 = !{!3, !3, i64 0}
!3 = !{!"int", !4, i64 0}
!4 = !{!"omnipotent char", !5, i64 0}
!5 = !{!"Simple C/C++ TBAA"}
```
to
```
; ModuleID = 'bbi-114859.c'
source_filename = "bbi-114859.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nounwind denormal_fpenv(float: preservesign)
define dso_local void @foo() local_unnamed_addr #0 {
entry:
%sqrtf = call float @sqrtf(float noundef -1.000000e+00) #1
ret void
}
; Function Attrs: mustprogress nocallback nofree nounwind willreturn denormal_fpenv(float: preservesign) memory(errnomem: write)
declare double @sqrt(double noundef) local_unnamed_addr #1
declare float @sqrtf(float)
attributes #0 = { nounwind denormal_fpenv(float: preservesign) "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn denormal_fpenv(float: preservesign) memory(errnomem: write) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
!llvm.module.flags = !{!0}
!llvm.ident = !{!1}
!llvm.errno.tbaa = !{!2}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 23.0.0git"}
!2 = !{!3, !3, i64 0}
!3 = !{!"int", !4, i64 0}
!4 = !{!"omnipotent char", !5, i64 0}
!5 = !{!"Simple C/C++ TBAA"}
```
and introduce the denormal_fpenv on the call site.
https://github.com/llvm/llvm-project/pull/174293
More information about the cfe-commits
mailing list