[llvm] [GIsel] Add combiner for constant-folding G_BITCAST (PR #193060)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon May 4 10:09:18 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}); }])>;
----------------
arsenm wrote:
> We need C++ logic in the match to ensure we don't match on bitcasts to vectors.
That should be constant foldable though
https://github.com/llvm/llvm-project/pull/193060
More information about the llvm-commits
mailing list