[llvm] [GIsel] Add combiner for constant-folding G_BITCAST (PR #193060)
Alex MacLean via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 22 19:18:24 PDT 2026
================
@@ -1390,6 +1394,23 @@ def constant_fold_cast_op : GICombineRule<
[{ return Helper.matchConstantFoldCastOp(*${d}, ${matchinfo}); }]),
(apply [{ Helper.replaceInstWithConstant(*${d}, ${matchinfo}); }])>;
+
+def constant_fold_bitcast_of_const : BuildFnCombineRule<
+ (match (G_CONSTANT $src, $imm),
+ (G_BITCAST $d, $src):$root,
+ [{ return Helper.matchConstantFoldBitcast(
+ ${d}, ${imm}.getCImm()->getValue(), ${matchinfo}); }])>;
----------------
AlexMaclean wrote:
I'm not sure I understand. I don't think this case is as simple. We need C++ logic in the match to ensure we don't match on bitcasts to vectors. We also need a C++ apply to construct the new constant.
https://github.com/llvm/llvm-project/pull/193060
More information about the llvm-commits
mailing list