diff --git a/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll b/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll index b24293cead4f..ee8a6451fe72 100644 --- a/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll +++ b/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll @@ -1,6 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -instsimplify -S | FileCheck %s +; fneg (fneg X) ==> X define float @fneg_fneg_var(float %a) { ; CHECK-LABEL: @fneg_fneg_var( ; CHECK-NEXT: ret float [[A:%.*]] @@ -10,6 +11,34 @@ define float @fneg_fneg_var(float %a) { ret float %r1 } +; fneg (fsub -0.0, X) ==> X +define float @fsub_-0_x(float %a) { +; CHECK-LABEL: @fsub_-0_x( +; CHECK-NEXT: ret float [[A:%.*]] +; + %t1 = fsub float -0.0, %a + %ret = fneg float %t1 + ret float %ret +} + +define <2 x float> @fsub_-0_x_vec(<2 x float> %a) { +; CHECK-LABEL: @fsub_-0_x_vec( +; CHECK-NEXT: ret <2 x float> [[A:%.*]] +; + %t1 = fsub <2 x float> , %a + %ret = fneg <2 x float> %t1 + ret <2 x float> %ret +} + +define <2 x float> @fsub_-0_x_vec_undef_elts(<2 x float> %a) { +; CHECK-LABEL: @fsub_-0_x_vec_undef_elts( +; CHECK-NEXT: ret <2 x float> [[A:%.*]] +; + %t1 = fsub <2 x float> , %a + %ret = fneg <2 x float> %t1 + ret <2 x float> %ret +} + define <2 x float> @fsub_negzero_vec_undef_elts(<2 x float> %x) { ; CHECK-LABEL: @fsub_negzero_vec_undef_elts( ; CHECK-NEXT: ret <2 x float> [[X:%.*]]