[llvm] [GlobalISel] Combine G_MERGE_VALUES of x and undef (PR #113616)
Thorsten Schütt via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 25 11:00:25 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 (isLegalOrBeforeLegalizer({TargetOpcode::G_CONSTANT, {DstTy}})) {
+ Builder.buildConstant(MI.getOperand(0), C);
+ MI.eraseFromParent();
+ }
----------------
tschuett wrote:
I am interested in root cause analysis. We are combining G_ZEXT of undef into 0 in this PR and it relies on this function. We never build something before checking legality. The change itself is not negotiable. You can ask to move into a separate PR of course.
https://github.com/llvm/llvm-project/pull/113616
More information about the llvm-commits
mailing list