Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions llvm/lib/Analysis/InstructionSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6306,6 +6306,11 @@ static Value *simplifyUnaryIntrinsic(Function *F, Value *Op0,
if (computeKnownFPSignBit(Op0, /*Depth=*/0, Q) == false)
return Op0;
break;
case Intrinsic::sqrt:
if (Value *V = simplifyFPOp(Op0, Call->getFastMathFlags(), Q, fp::ebIgnore,
RoundingMode::NearestTiesToEven))
return V;
break;
case Intrinsic::bswap:
// bswap(bswap(x)) -> x
if (match(Op0, m_BSwap(m_Value(X))))
Expand Down
40 changes: 40 additions & 0 deletions llvm/test/Transforms/InstSimplify/fp-undef-poison.ll
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,43 @@ define double @fmul_nnan_inf_op1(double %x) {
%r = fmul nnan double %x, 0xfff0000000000000
ret double %r
}

define float @sqrt_poison() {
; CHECK-LABEL: @sqrt_poison(
; CHECK-NEXT: ret float poison
;
%sqrt = call float @llvm.sqrt(float poison)
ret float %sqrt
}

define <2 x float> @sqrt_poison_fixed_vec() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a case with <float 1.0, float poison>?

; CHECK-LABEL: @sqrt_poison_fixed_vec(
; CHECK-NEXT: ret <2 x float> poison
;
%sqrt = call <2 x float> @llvm.sqrt(<2 x float> poison)
ret <2 x float> %sqrt
}

define <vscale x 2 x float> @sqrt_poison_scalable_vec() {
; CHECK-LABEL: @sqrt_poison_scalable_vec(
; CHECK-NEXT: ret <vscale x 2 x float> poison
;
%sqrt = call <vscale x 2 x float> @llvm.sqrt(<vscale x 2 x float> poison)
ret <vscale x 2 x float> %sqrt
}

define float @sqrt_nnan_nan() {
; CHECK-LABEL: @sqrt_nnan_nan(
; CHECK-NEXT: ret float poison
;
%sqrt = call nnan float @llvm.sqrt(float 0x7ff8000000000000)
ret float %sqrt
}

define float @sqrt_ninf_inf() {
; CHECK-LABEL: @sqrt_ninf_inf(
; CHECK-NEXT: ret float poison
;
%sqrt = call ninf float @llvm.sqrt(float 0xfff0000000000000)
ret float %sqrt
}
Loading