Skip to content

InstCombine: Enable SimplifyDemandedUseFPClass and remove flag #81108

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

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 44 additions & 12 deletions clang/test/Headers/__clang_hip_math.hip
Original file line number Diff line number Diff line change
Expand Up @@ -2557,33 +2557,65 @@ extern "C" __device__ double test_nan(const char *tag) {
return nan(tag);
}

// CHECK-LABEL: @test_nanf_emptystr(
// CHECK-NEXT: entry:
// CHECK-NEXT: ret float 0x7FF8000000000000
// DEFAULT-LABEL: @test_nanf_emptystr(
// DEFAULT-NEXT: entry:
// DEFAULT-NEXT: ret float 0x7FF8000000000000
//
// FINITEONLY-LABEL: @test_nanf_emptystr(
// FINITEONLY-NEXT: entry:
// FINITEONLY-NEXT: ret float poison
//
// APPROX-LABEL: @test_nanf_emptystr(
// APPROX-NEXT: entry:
// APPROX-NEXT: ret float 0x7FF8000000000000
//
extern "C" __device__ float test_nanf_emptystr() {
return nanf("");
}

// CHECK-LABEL: @test_nan_emptystr(
// CHECK-NEXT: entry:
// CHECK-NEXT: ret double 0x7FF8000000000000
// DEFAULT-LABEL: @test_nan_emptystr(
// DEFAULT-NEXT: entry:
// DEFAULT-NEXT: ret double 0x7FF8000000000000
//
// FINITEONLY-LABEL: @test_nan_emptystr(
// FINITEONLY-NEXT: entry:
// FINITEONLY-NEXT: ret double poison
//
// APPROX-LABEL: @test_nan_emptystr(
// APPROX-NEXT: entry:
// APPROX-NEXT: ret double 0x7FF8000000000000
//
extern "C" __device__ double test_nan_emptystr() {
return nan("");
}

// CHECK-LABEL: @test_nanf_fill(
// CHECK-NEXT: entry:
// CHECK-NEXT: ret float 0x7FF8000000000000
// DEFAULT-LABEL: @test_nanf_fill(
// DEFAULT-NEXT: entry:
// DEFAULT-NEXT: ret float 0x7FF8000000000000
//
// FINITEONLY-LABEL: @test_nanf_fill(
// FINITEONLY-NEXT: entry:
// FINITEONLY-NEXT: ret float poison
//
// APPROX-LABEL: @test_nanf_fill(
// APPROX-NEXT: entry:
// APPROX-NEXT: ret float 0x7FF8000000000000
//
extern "C" __device__ float test_nanf_fill() {
return nanf("0x456");
}

// CHECK-LABEL: @test_nan_fill(
// CHECK-NEXT: entry:
// CHECK-NEXT: ret double 0x7FF8000000000000
// DEFAULT-LABEL: @test_nan_fill(
// DEFAULT-NEXT: entry:
// DEFAULT-NEXT: ret double 0x7FF8000000000000
//
// FINITEONLY-LABEL: @test_nan_fill(
// FINITEONLY-NEXT: entry:
// FINITEONLY-NEXT: ret double poison
//
// APPROX-LABEL: @test_nan_fill(
// APPROX-NEXT: entry:
// APPROX-NEXT: ret double 0x7FF8000000000000
//
extern "C" __device__ double test_nan_fill() {
return nan("0x123");
Expand Down
9 changes: 0 additions & 9 deletions llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,6 @@ static cl::opt<unsigned>
MaxArraySize("instcombine-maxarray-size", cl::init(1024),
cl::desc("Maximum array size considered when doing a combine"));

// TODO: Remove this option
static cl::opt<bool> EnableSimplifyDemandedUseFPClass(
"instcombine-simplify-demanded-fp-class",
cl::desc("Enable demanded floating-point class optimizations"),
cl::init(false));

// FIXME: Remove this flag when it is no longer necessary to convert
// llvm.dbg.declare to avoid inaccurate debug info. Setting this to false
// increases variable availability at the cost of accuracy. Variables that
Expand Down Expand Up @@ -3111,9 +3105,6 @@ Instruction *InstCombinerImpl::visitFree(CallInst &FI, Value *Op) {
}

Instruction *InstCombinerImpl::visitReturnInst(ReturnInst &RI) {
if (!EnableSimplifyDemandedUseFPClass)
return nullptr;

Value *RetVal = RI.getReturnValue();
if (!RetVal || !AttributeFuncs::isNoFPClassCompatibleType(RetVal->getType()))
return nullptr;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
; RUN: opt -S -passes=instcombine -instcombine-simplify-demanded-fp-class < %s | FileCheck %s
; RUN: opt -S -passes=instcombine < %s | FileCheck %s

declare float @llvm.fabs.f32(float)
declare float @llvm.copysign.f32(float, float)
Expand Down