[InstCombine] add tests for fabs(x) / fabs (x); NFC

This commit is contained in:
Sanjay Patel 2020-06-20 09:52:12 -04:00
parent 89dcbdfcfd
commit 61b5773796
1 changed files with 26 additions and 0 deletions

View File

@ -1,6 +1,8 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -instcombine < %s | FileCheck %s ; RUN: opt -S -instcombine < %s | FileCheck %s
declare float @llvm.fabs.f32(float) nounwind readnone
define float @exact_inverse(float %x) { define float @exact_inverse(float %x) {
; CHECK-LABEL: @exact_inverse( ; CHECK-LABEL: @exact_inverse(
; CHECK-NEXT: [[DIV:%.*]] = fmul float [[X:%.*]], 1.250000e-01 ; CHECK-NEXT: [[DIV:%.*]] = fmul float [[X:%.*]], 1.250000e-01
@ -570,3 +572,27 @@ define float @fdiv_fneg1_extra_use(float %x, float %y) {
%div = fdiv float %neg, %y %div = fdiv float %neg, %y
ret float %div ret float %div
} }
define float @fabs_same_op(float %x) {
; CHECK-LABEL: @fabs_same_op(
; CHECK-NEXT: [[A:%.*]] = call float @llvm.fabs.f32(float [[X:%.*]])
; CHECK-NEXT: [[R:%.*]] = fdiv float [[A]], [[A]]
; CHECK-NEXT: ret float [[R]]
;
%a = call float @llvm.fabs.f32(float %x)
%r = fdiv float %a, %a
ret float %r
}
define float @fabs_same_op_extra_use(float %x) {
; CHECK-LABEL: @fabs_same_op_extra_use(
; CHECK-NEXT: [[A:%.*]] = call float @llvm.fabs.f32(float [[X:%.*]])
; CHECK-NEXT: call void @use_f32(float [[A]])
; CHECK-NEXT: [[R:%.*]] = fdiv reassoc ninf float [[A]], [[A]]
; CHECK-NEXT: ret float [[R]]
;
%a = call float @llvm.fabs.f32(float %x)
call void @use_f32(float %a)
%r = fdiv ninf reassoc float %a, %a
ret float %r
}