[llvm] [GlobalISel] Combine G_ZEXT of undef -> 0 (PR #113764)
Thorsten Schütt via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 29 13:59:31 PDT 2024
================
@@ -2916,8 +2916,11 @@ void CombinerHelper::replaceInstWithFConstant(MachineInstr &MI, double C) {
void CombinerHelper::replaceInstWithConstant(MachineInstr &MI, int64_t C) {
assert(MI.getNumDefs() == 1 && "Expected only one def?");
- Builder.buildConstant(MI.getOperand(0), C);
- MI.eraseFromParent();
+ LLT DstTy = MRI.getType(MI.getOperand(0).getReg());
+ if (isConstantLegalOrBeforeLegalizer(DstTy)) {
----------------
tschuett wrote:
Let's go one step back. This discussion is unrelated to this PR. What is it that you don't like about this PR:
* I fixed a bug. We build constants without checking for legality.
* The legality check is too close to the build and you would rather see it 100 miles afar from the build.
* Otherwise, I would need some help to understand the unhappiness.
https://github.com/llvm/llvm-project/pull/113764
More information about the llvm-commits
mailing list