Convert "denormal-fp-math" and "denormal-fp-math-f32" into a first class denormal_fpenv attribute. Previously the query for the effective denormal mode involved two string attribute queries with parsing. I'm introducing more uses of this, so it makes sense to convert this to a more efficient encoding. The old representation was also awkward since it was split across two separate attributes. The new encoding just stores the default and float modes as bitfields, largely avoiding the need to consider if the other mode is set. The syntax in the common cases looks like this: `denormal_fpenv(preservesign,preservesign)` `denormal_fpenv(float: preservesign,preservesign)` `denormal_fpenv(dynamic,dynamic float: preservesign,preservesign)` I wasn't sure about reusing the float type name instead of adding a new keyword. It's parsed as a type but only accepts float. I'm also debating switching the name to subnormal to match the current preferred IEEE terminology (also used by nofpclass and other contexts). This has a behavior change when using the command flag debug options to set the denormal mode. The behavior of the flag ignored functions with an explicit attribute set, per the default and f32 version. Now that these are one attribute, the flag logic can't distinguish which of the two components were explicitly set on the function. Only one test appeared to rely on this behavior, so I just avoided using the flags in it. This also does not perform all the code cleanups this enables. In particular the attributor handling could be cleaned up. I also guessed at how to support this in MLIR. I followed MemoryEffects as a reference; it appears bitfields are expanded into arguments to attributes, so the representation there is a bit uglier with the 2 2-element fields flattened into 4 arguments.
36 lines
1.7 KiB
LLVM
36 lines
1.7 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
; RUN: llc -mtriple=thumbv7em-arm-none-eabi < %s | FileCheck %s
|
|
|
|
target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
|
|
target triple = "thumbv7em-arm-none-eabi"
|
|
|
|
@a = hidden global i32 0, align 4
|
|
|
|
define hidden void @fn1() nounwind #0 {
|
|
; CHECK-LABEL: fn1:
|
|
; CHECK: @ %bb.0: @ %entry
|
|
; CHECK-NEXT: movs r0, #1
|
|
; CHECK-NEXT: cbnz r0, .LBB0_2
|
|
; CHECK-NEXT: b .LBB0_1
|
|
; CHECK-NEXT: .LBB0_1: @ %land.rhs
|
|
; CHECK-NEXT: b .LBB0_2
|
|
; CHECK-NEXT: .LBB0_2: @ %land.end
|
|
; CHECK-NEXT: bx lr
|
|
entry:
|
|
%0 = load i32, ptr @a, align 4
|
|
%conv = sitofp i32 %0 to double
|
|
%mul = fmul nnan ninf nsz double 0.000000e+00, %conv
|
|
%tobool = fcmp nnan ninf nsz une double %mul, 0.000000e+00
|
|
br i1 %tobool, label %land.rhs, label %land.end
|
|
|
|
land.rhs: ; preds = %entry
|
|
br label %land.end
|
|
|
|
land.end: ; preds = %land.rhs, %entry
|
|
%1 = phi i1 [ false, %entry ], [ false, %land.rhs ]
|
|
%land.ext = zext i1 %1 to i32
|
|
ret void
|
|
}
|
|
|
|
attributes #0 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" denormal_fpenv(preservesign) "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="true" "no-jump-tables"="false" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="cortex-m4" "target-features"="+armv7e-m,+dsp,+fp16,+hwdiv,+thumb-mode,+vfp2sp,+vfp3d16sp,+vfp4d16sp,-aes,-crc,-crypto,-dotprod,-fp16fml,-fullfp16,-hwdiv-arm,-lob,-mve,-mve.fp,-ras,-sb,-sha2" "use-soft-float"="false" }
|