[InstSimplify] add tests with NaN operand for fp binops; NFC

llvm-svn: 327631
This commit is contained in:
Sanjay Patel 2018-03-15 14:48:39 +00:00
parent fb7aa57bf1
commit 43f71eade0
1 changed files with 185 additions and 0 deletions

View File

@ -0,0 +1,185 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instsimplify -S | FileCheck %s
define float @fadd_nan_op0(float %x) {
; CHECK-LABEL: @fadd_nan_op0(
; CHECK-NEXT: [[R:%.*]] = fadd float 0x7FF8000000000000, [[X:%.*]]
; CHECK-NEXT: ret float [[R]]
;
%r = fadd float 0x7FF8000000000000, %x
ret float %r
}
define float @fadd_nan_op1(float %x) {
; CHECK-LABEL: @fadd_nan_op1(
; CHECK-NEXT: [[R:%.*]] = fadd float [[X:%.*]], 0x7FF8000000000000
; CHECK-NEXT: ret float [[R]]
;
%r = fadd float %x, 0x7FF8000000000000
ret float %r
}
define float @fsub_nan_op0(float %x) {
; CHECK-LABEL: @fsub_nan_op0(
; CHECK-NEXT: [[R:%.*]] = fsub float 0x7FF8000000000000, [[X:%.*]]
; CHECK-NEXT: ret float [[R]]
;
%r = fsub float 0x7FF8000000000000, %x
ret float %r
}
define float @fsub_nan_op1(float %x) {
; CHECK-LABEL: @fsub_nan_op1(
; CHECK-NEXT: [[R:%.*]] = fsub float [[X:%.*]], 0x7FF8000000000000
; CHECK-NEXT: ret float [[R]]
;
%r = fsub float %x, 0x7FF8000000000000
ret float %r
}
define float @fmul_nan_op0(float %x) {
; CHECK-LABEL: @fmul_nan_op0(
; CHECK-NEXT: [[R:%.*]] = fmul float 0x7FF8000000000000, [[X:%.*]]
; CHECK-NEXT: ret float [[R]]
;
%r = fmul float 0x7FF8000000000000, %x
ret float %r
}
define float @fmul_nan_op1(float %x) {
; CHECK-LABEL: @fmul_nan_op1(
; CHECK-NEXT: [[R:%.*]] = fmul float [[X:%.*]], 0x7FF8000000000000
; CHECK-NEXT: ret float [[R]]
;
%r = fmul float %x, 0x7FF8000000000000
ret float %r
}
define float @fdiv_nan_op0(float %x) {
; CHECK-LABEL: @fdiv_nan_op0(
; CHECK-NEXT: [[R:%.*]] = fdiv float 0x7FF8000000000000, [[X:%.*]]
; CHECK-NEXT: ret float [[R]]
;
%r = fdiv float 0x7FF8000000000000, %x
ret float %r
}
define float @fdiv_nan_op1(float %x) {
; CHECK-LABEL: @fdiv_nan_op1(
; CHECK-NEXT: [[R:%.*]] = fdiv float [[X:%.*]], 0x7FF8000000000000
; CHECK-NEXT: ret float [[R]]
;
%r = fdiv float %x, 0x7FF8000000000000
ret float %r
}
define float @frem_nan_op0(float %x) {
; CHECK-LABEL: @frem_nan_op0(
; CHECK-NEXT: [[R:%.*]] = frem float 0x7FF8000000000000, [[X:%.*]]
; CHECK-NEXT: ret float [[R]]
;
%r = frem float 0x7FF8000000000000, %x
ret float %r
}
define float @frem_nan_op1(float %x) {
; CHECK-LABEL: @frem_nan_op1(
; CHECK-NEXT: [[R:%.*]] = frem float [[X:%.*]], 0x7FF8000000000000
; CHECK-NEXT: ret float [[R]]
;
%r = frem float %x, 0x7FF8000000000000
ret float %r
}
; Repeat all tests with fast-math-flags. Alternate 'nnan' and 'fast' for more coverage.
define float @fadd_nan_op0_nnan(float %x) {
; CHECK-LABEL: @fadd_nan_op0_nnan(
; CHECK-NEXT: [[R:%.*]] = fadd nnan float 0x7FF8000000000000, [[X:%.*]]
; CHECK-NEXT: ret float [[R]]
;
%r = fadd nnan float 0x7FF8000000000000, %x
ret float %r
}
define float @fadd_nan_op1_fast(float %x) {
; CHECK-LABEL: @fadd_nan_op1_fast(
; CHECK-NEXT: [[R:%.*]] = fadd fast float [[X:%.*]], 0x7FF8000000000000
; CHECK-NEXT: ret float [[R]]
;
%r = fadd fast float %x, 0x7FF8000000000000
ret float %r
}
define float @fsub_nan_op0_fast(float %x) {
; CHECK-LABEL: @fsub_nan_op0_fast(
; CHECK-NEXT: [[R:%.*]] = fsub fast float 0x7FF8000000000000, [[X:%.*]]
; CHECK-NEXT: ret float [[R]]
;
%r = fsub fast float 0x7FF8000000000000, %x
ret float %r
}
define float @fsub_nan_op1_nnan(float %x) {
; CHECK-LABEL: @fsub_nan_op1_nnan(
; CHECK-NEXT: [[R:%.*]] = fsub nnan float [[X:%.*]], 0x7FF8000000000000
; CHECK-NEXT: ret float [[R]]
;
%r = fsub nnan float %x, 0x7FF8000000000000
ret float %r
}
define float @fmul_nan_op0_nnan(float %x) {
; CHECK-LABEL: @fmul_nan_op0_nnan(
; CHECK-NEXT: [[R:%.*]] = fmul nnan float 0x7FF8000000000000, [[X:%.*]]
; CHECK-NEXT: ret float [[R]]
;
%r = fmul nnan float 0x7FF8000000000000, %x
ret float %r
}
define float @fmul_nan_op1_fast(float %x) {
; CHECK-LABEL: @fmul_nan_op1_fast(
; CHECK-NEXT: [[R:%.*]] = fmul fast float [[X:%.*]], 0x7FF8000000000000
; CHECK-NEXT: ret float [[R]]
;
%r = fmul fast float %x, 0x7FF8000000000000
ret float %r
}
define float @fdiv_nan_op0_fast(float %x) {
; CHECK-LABEL: @fdiv_nan_op0_fast(
; CHECK-NEXT: [[R:%.*]] = fdiv fast float 0x7FF8000000000000, [[X:%.*]]
; CHECK-NEXT: ret float [[R]]
;
%r = fdiv fast float 0x7FF8000000000000, %x
ret float %r
}
define float @fdiv_nan_op1_nnan(float %x) {
; CHECK-LABEL: @fdiv_nan_op1_nnan(
; CHECK-NEXT: [[R:%.*]] = fdiv nnan float [[X:%.*]], 0x7FF8000000000000
; CHECK-NEXT: ret float [[R]]
;
%r = fdiv nnan float %x, 0x7FF8000000000000
ret float %r
}
define float @frem_nan_op0_nnan(float %x) {
; CHECK-LABEL: @frem_nan_op0_nnan(
; CHECK-NEXT: [[R:%.*]] = frem nnan float 0x7FF8000000000000, [[X:%.*]]
; CHECK-NEXT: ret float [[R]]
;
%r = frem nnan float 0x7FF8000000000000, %x
ret float %r
}
define float @frem_nan_op1_fast(float %x) {
; CHECK-LABEL: @frem_nan_op1_fast(
; CHECK-NEXT: [[R:%.*]] = frem fast float [[X:%.*]], 0x7FF8000000000000
; CHECK-NEXT: ret float [[R]]
;
%r = frem fast float %x, 0x7FF8000000000000
ret float %r
}