[llvm] 61b5773 - [InstCombine] add tests for fabs(x) / fabs (x); NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 20 07:21:42 PDT 2020
Author: Sanjay Patel
Date: 2020-06-20T10:17:09-04:00
New Revision: 61b5773796c75e8021f9f476da49fc1c0a5dd1bb
URL: https://github.com/llvm/llvm-project/commit/61b5773796c75e8021f9f476da49fc1c0a5dd1bb
DIFF: https://github.com/llvm/llvm-project/commit/61b5773796c75e8021f9f476da49fc1c0a5dd1bb.diff
LOG: [InstCombine] add tests for fabs(x) / fabs (x); NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/fdiv.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/fdiv.ll b/llvm/test/Transforms/InstCombine/fdiv.ll
index 888f5e8f9c32..c5ea7413ab5e 100644
--- a/llvm/test/Transforms/InstCombine/fdiv.ll
+++ b/llvm/test/Transforms/InstCombine/fdiv.ll
@@ -1,6 +1,8 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -instcombine < %s | FileCheck %s
+declare float @llvm.fabs.f32(float) nounwind readnone
+
define float @exact_inverse(float %x) {
; CHECK-LABEL: @exact_inverse(
; 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
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
+}
More information about the llvm-commits
mailing list