[llvm] [InstCombine] Use InstSimplify in FoldOpIntoSelect (PR #116073)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 13 08:59:33 PST 2024


================
@@ -52,7 +52,7 @@ define <2 x half> @fmul_constant_op1(<2 x float> %x) {
 define float @fptrunc_select_true_val(float %x, double %y, i1 %cond) {
 ; CHECK-LABEL: @fptrunc_select_true_val(
 ; CHECK-NEXT:    [[TMP1:%.*]] = fptrunc double [[Y:%.*]] to float
-; CHECK-NEXT:    [[NARROW_SEL:%.*]] = select fast i1 [[COND:%.*]], float [[TMP1]], float [[X:%.*]]
+; CHECK-NEXT:    [[NARROW_SEL:%.*]] = select i1 [[COND:%.*]], float [[TMP1]], float [[X:%.*]]
----------------
nikic wrote:

This was previously handled by https://github.com/llvm/llvm-project/blob/2ca25ab11d01ceacf359643b09aed7d53d0ff8dc/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp#L1870-L1887, which preserves FMF.

However, I don't think that FMF preservation is actually correct. Let's say y is a big double and the fptrunc of it results in INF. Then we will violate ninf while we did not before.

I think we should drop that separate fold after this PR lands.

https://github.com/llvm/llvm-project/pull/116073


More information about the llvm-commits mailing list