[llvm] [InstCombine] Fold more 'fcmp' 'select' instrs idioms into 'fabs' (PR #83381)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 1 01:04:13 PST 2024
================
@@ -839,6 +868,35 @@ define <2 x float> @select_fcmp_nnan_nsz_ugt_zero_unary_fneg(<2 x float> %x) {
ret <2 x float> %fabs
}
+define float @absfloat32f_ogt_fast_no_signed_zeroes(float %x) "no-signed-zeros-fp-math" {
+; CHECK-LABEL: @absfloat32f_ogt_fast_no_signed_zeroes(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[RETVAL_0:%.*]] = call nnan ninf float @llvm.fabs.f32(float [[X:%.*]])
+; CHECK-NEXT: ret float [[RETVAL_0]]
+;
+entry:
+ %cmp = fcmp fast ogt float %x, 0.000000e+00
+ %fneg = fneg fast float %x
+ %retval.0 = select i1 %cmp, float %x, float %fneg
+ ret float %retval.0
+}
+
+define float @absfloat32f_ogt_fast_no_no_signed_zeroes(float %x) {
+; CHECK-LABEL: @absfloat32f_ogt_fast_no_no_signed_zeroes(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP:%.*]] = fcmp fast ogt float [[X:%.*]], 0.000000e+00
+; CHECK-NEXT: [[FNEG:%.*]] = fneg fast float [[X]]
+; CHECK-NEXT: [[RETVAL_0:%.*]] = select nnan ninf i1 [[CMP]], float [[X]], float [[FNEG]]
+; CHECK-NEXT: ret float [[RETVAL_0]]
+;
+entry:
+ %cmp = fcmp fast ogt float %x, 0.000000e+00
+ %fneg = fneg fast float %x
----------------
arsenm wrote:
Reduce set of flags in tests
https://github.com/llvm/llvm-project/pull/83381
More information about the llvm-commits
mailing list