[llvm] [GlobalISel] Combine G_ZEXT of undef -> 0 (PR #113764)
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 26 12:55:05 PDT 2024
Thorsten =?utf-8?q?Schütt?= <schuett at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/113764 at github.com>
================
@@ -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)) {
----------------
aemerson wrote:
A function called `replaceInstWithConstant` intended to be a helper routine should do as it's told. You can see in the above example it's easy to assume that it does in fact replace the MI as requested and therefore we'd get bugs. It's about fixing problems in the most natural place.
> This sentence is wrong.
I don't know what you expected to achieve with this comment but it's not helpful. Matt was trying to say that this issue should be fixed in the matcher.
https://github.com/llvm/llvm-project/pull/113764
More information about the llvm-commits
mailing list