aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorQuentin Colombet <quentin.colombet@gmail.com>2024-06-08 11:31:13 +0200
committerGitHub <noreply@github.com>2024-06-08 11:31:13 +0200
commit25506f48643b65e48c6bd501855589fff8983933 (patch)
treecb3f6210ddc0e553bb5dcd1faf25e8125c3d9d71 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parent9ddc014f1a588608af1f08051d084c5839a41a80 (diff)
downloadllvm-25506f48643b65e48c6bd501855589fff8983933.zip
llvm-25506f48643b65e48c6bd501855589fff8983933.tar.gz
llvm-25506f48643b65e48c6bd501855589fff8983933.tar.bz2
[SDISel][Combine] Constant fold FP16_TO_FP (#94790)
In some case, constant can survive early constant folding optimization because they are hidden behind several layers of type changes. E.g., consider the following sequence (extracted from the arm test that this commit changes): ``` t2: v1f16 = BUILD_VECTOR ConstantFP:f16<APFloat(0)> t4: v1f16 = insert_vector_elt t2, ConstantFP:f16<APFloat(0)>, Constant:i32<0> t5: f16 = bitcast t4 t6: f32 = fp_extend t5 ``` Because the constant (APFloat(0)) is hidden behind a <1 x ty> type, all the constant folding that normally happen for scalar nodes when using `SelectionDAG::getNode` are blocked. As a result the constant manages to survive as an actual conversion instruction down to the select phase: ``` t11: f32 = fp16_to_fp Constant:i32<0> ``` With the change in this patch, we try to do constant folding one more time during dag combine, which in the motivating example result in the much better sequence: ``` t7: ch = CopyToReg t0, Register:f32 %0, ConstantFP:f32<0.000000e+00> ``` Note: I'm sure we have this problem in a lot of other places. Generally speaking I believe SDISel is not that good with <1 x ty> compared to pure scalar. However, I only changed what I could easily test.
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
0 files changed, 0 insertions, 0 deletions