-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Constant Fold Logf128 calls #84501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constant Fold Logf128 calls #84501
Changes from all commits
af03313
d959ed9
d862a1a
ca14318
48e5f1b
24af579
5f96eae
6a08ef5
8427d6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//===-- llvm/Support/float128.h - Compiler abstraction support --*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_FLOAT128 | ||
#define LLVM_FLOAT128 | ||
|
||
namespace llvm { | ||
|
||
#if defined(__clang__) && defined(__FLOAT128__) | ||
typedef __float128 float128; | ||
#elif defined(__FLOAT128__) && (defined(__GNUC__) || defined(__GNUG__)) | ||
typedef _Float128 float128; | ||
#endif | ||
|
||
} // namespace llvm | ||
#endif // LLVM_FLOAT128 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 | ||
; RUN: opt < %s -passes=instsimplify -S | FileCheck %s | ||
|
||
; REQUIRES: has_logf128 | ||
declare fp128 @llvm.log.f128(fp128) | ||
|
||
define fp128 @log_e_64(){ | ||
; CHECK-LABEL: define fp128 @log_e_64() { | ||
; CHECK-NEXT: ret fp128 0xL300000000000000040010A2B23F3BAB7 | ||
; | ||
%A = call fp128 @llvm.log.f128(fp128 noundef 0xL00000000000000004005000000000000) | ||
ret fp128 %A | ||
} | ||
|
||
define fp128 @log_e_smallest_positive_subnormal_number(){ | ||
; CHECK-LABEL: define fp128 @log_e_smallest_positive_subnormal_number() { | ||
; CHECK-NEXT: ret fp128 0xL3000000000000000C00C654628220780 | ||
; | ||
%A = call fp128 @llvm.log.f128(fp128 noundef 0xL00000000000000010000000000000000) | ||
ret fp128 %A | ||
} | ||
|
||
define fp128 @log_e_largest_subnormal_number(){ | ||
; CHECK-LABEL: define fp128 @log_e_largest_subnormal_number() { | ||
; CHECK-NEXT: ret fp128 0xLD000000000000000C00C62D918CE2421 | ||
; | ||
%A = call fp128 @llvm.log.f128(fp128 noundef 0xLFFFFFFFFFFFFFFFF0000FFFFFFFFFFFF) | ||
ret fp128 %A | ||
} | ||
|
||
define fp128 @log_e_smallest_positive_normal_number(){ | ||
; | ||
; CHECK-LABEL: define fp128 @log_e_smallest_positive_normal_number() { | ||
; CHECK-NEXT: ret fp128 0xLD000000000000000C00C62D918CE2421 | ||
; | ||
%A = call fp128 @llvm.log.f128(fp128 noundef 0xL00000000000000000001000000000000) | ||
ret fp128 %A | ||
} | ||
|
||
define fp128 @log_e_largest_normal_number(){ | ||
; CHECK-LABEL: define fp128 @log_e_largest_normal_number() { | ||
; CHECK-NEXT: ret fp128 0xLF000000000000000400C62E42FEFA39E | ||
; | ||
%A = call fp128 @llvm.log.f128(fp128 noundef 0xLFFFFFFFFFFFFFFFF7FFEFFFFFFFFFFFF) | ||
ret fp128 %A | ||
} | ||
|
||
define fp128 @log_e_largest_number_less_than_one(){ | ||
; CHECK-LABEL: define fp128 @log_e_largest_number_less_than_one() { | ||
; CHECK-NEXT: ret fp128 0xL0000000000000000BF8E000000000000 | ||
; | ||
%A = call fp128 @llvm.log.f128(fp128 noundef 0xLFFFFFFFFFFFFFFFF3FFEFFFFFFFFFFFF) | ||
ret fp128 %A | ||
} | ||
|
||
define fp128 @log_e_1(){ | ||
; CHECK-LABEL: define fp128 @log_e_1() { | ||
; CHECK-NEXT: ret fp128 0xL00000000000000000000000000000000 | ||
; | ||
%A = call fp128 @llvm.log.f128(fp128 noundef 0xL00000000000000003FFF000000000000) | ||
ret fp128 %A | ||
} | ||
|
||
define fp128 @log_e_smallest_number_larger_than_one(){ | ||
; CHECK-LABEL: define fp128 @log_e_smallest_number_larger_than_one() { | ||
; CHECK-NEXT: ret fp128 0xL00000000000000003F8F000000000000 | ||
; | ||
%A = call fp128 @llvm.log.f128(fp128 noundef 0xL00000000000000013FFF000000000000) | ||
ret fp128 %A | ||
} | ||
|
||
define fp128 @log_e_negative_2(){ | ||
; CHECK-LABEL: define fp128 @log_e_negative_2() { | ||
; CHECK-NEXT: ret fp128 0xL00000000000000007FFF800000000000 | ||
; | ||
%A = call fp128 @llvm.log.f128(fp128 noundef 0xL0000000000000000C000000000000000) | ||
ret fp128 %A | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test inf/nan/zero There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added. |
||
|
||
define fp128 @log_e_0(){ | ||
; CHECK-LABEL: define fp128 @log_e_0() { | ||
; CHECK-NEXT: ret fp128 0xL0000000000000000FFFF000000000000 | ||
; | ||
%A = call fp128 @llvm.log.f128(fp128 noundef 0xL00000000000000000000000000000000) | ||
ret fp128 %A | ||
} | ||
|
||
define fp128 @log_e_negative_0(){ | ||
; CHECK-LABEL: define fp128 @log_e_negative_0() { | ||
; CHECK-NEXT: ret fp128 0xL0000000000000000FFFF000000000000 | ||
; | ||
%A = call fp128 @llvm.log.f128(fp128 noundef 0xL00000000000000008000000000000000) | ||
ret fp128 %A | ||
} | ||
|
||
define fp128 @log_e_infinity(){ | ||
; CHECK-LABEL: define fp128 @log_e_infinity() { | ||
; CHECK-NEXT: ret fp128 0xL00000000000000007FFF000000000000 | ||
; | ||
%A = call fp128 @llvm.log.f128(fp128 noundef 0xL00000000000000007FFF000000000000) | ||
ret fp128 %A | ||
} | ||
|
||
define fp128 @log_e_negative_infinity(){ | ||
; CHECK-LABEL: define fp128 @log_e_negative_infinity() { | ||
; CHECK-NEXT: ret fp128 0xL00000000000000007FFF800000000000 | ||
; | ||
%A = call fp128 @llvm.log.f128(fp128 noundef 0xL0000000000000000FFFF000000000000) | ||
ret fp128 %A | ||
} | ||
|
||
define fp128 @log_e_nan(){ | ||
; CHECK-LABEL: define fp128 @log_e_nan() { | ||
; CHECK-NEXT: ret fp128 0xL00000000000000007FFF800000000001 | ||
; | ||
%A = call fp128 @llvm.log.f128(fp128 noundef 0xL00000000000000007FFF000000000001) | ||
ret fp128 %A | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test vectors? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what you mean, sorry. I initially thought you meant the log function can take a vector type parameter, but after checking https://llvm.org/docs/LangRef.html#llvm-log-intrinsic I can't see one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I've added that test now. |
||
|
||
define <2 x fp128> @log_e_negative_2_vector(){ | ||
; CHECK-LABEL: define <2 x fp128> @log_e_negative_2_vector() { | ||
; CHECK-NEXT: ret <2 x fp128> <fp128 0xL00000000000000007FFF800000000000, fp128 0xL00000000000000007FFF800000000000> | ||
; | ||
%A = call <2 x fp128> @llvm.log.v2f128(<2 x fp128> <fp128 0xL0000000000000000C000000000000000, fp128 0xL0000000000000000C000000000000001>) | ||
ret <2 x fp128> %A | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
namespace llvm
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.