1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00
llvm-mirror/test/CodeGen/X86/strict-fadd-combines.ll
Drew Wock 2a5c21f1b1 [FPEnv] Allow fneg + strict_fadd -> strict_fsub in DAGCombiner
This is the first of a set of DAGCombiner changes enabling strictfp
optimizations. I want to test to waters with this to make sure changes
like these are acceptable for the strictfp case- this particular change
should preserve exception ordering and result precision perfectly, and
many other possible changes appear to be able to as well.

Copied from regular fadd combines but modified to preserve ordering via
the chain, this change allows strict_fadd x, (fneg y) to become
struct_fsub x, y and strict_fadd (fneg x), y to become strict_fsub y, x.

Differential Revision: https://reviews.llvm.org/D85548
2020-08-27 08:17:01 -04:00

38 lines
1.4 KiB
LLVM

; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
define float @fneg_strict_fadd_to_strict_fsub(float %x, float %y) {
; CHECK: subss %{{.*}}, %{{.*}}
; CHECK-NEXT: retq
%neg = fneg float %y
%add = call float @llvm.experimental.constrained.fadd.f32(float %x, float %neg, metadata!"round.dynamic", metadata!"fpexcept.strict")
ret float %add
}
define float @fneg_strict_fadd_to_strict_fsub_2(float %x, float %y) {
; CHECK: subss %{{.*}}, %{{.*}}
; CHECK-NEXT: retq
%neg = fneg float %y
%add = call float @llvm.experimental.constrained.fadd.f32(float %neg, float %x, metadata!"round.dynamic", metadata!"fpexcept.strict")
ret float %add
}
define double @fneg_strict_fadd_to_strict_fsub_d(double %x, double %y) {
; CHECK: subsd %{{.*}}, %{{.*}}
; CHECK-NEXT: retq
%neg = fneg double %y
%add = call double @llvm.experimental.constrained.fadd.f64(double %x, double %neg, metadata!"round.dynamic", metadata!"fpexcept.strict")
ret double %add
}
define double @fneg_strict_fadd_to_strict_fsub_2d(double %x, double %y) {
; CHECK: subsd %{{.*}}, %{{.*}}
; CHECK-NEXT: retq
%neg = fneg double %y
%add = call double @llvm.experimental.constrained.fadd.f64(double %neg, double %x, metadata!"round.dynamic", metadata!"fpexcept.strict")
ret double %add
}
declare float @llvm.experimental.constrained.fadd.f32(float, float, metadata, metadata)
declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata)