Index: lib/Target/AArch64/AArch64InstructionSelector.cpp =================================================================== --- lib/Target/AArch64/AArch64InstructionSelector.cpp +++ lib/Target/AArch64/AArch64InstructionSelector.cpp @@ -1165,8 +1165,18 @@ case TargetOpcode::G_INTTOPTR: + // Imported SelectionDAG rules can handle everything except pointer types + // which didn't exist in that instruction selector. + if (MRI.getType(I.getOperand(0).getReg()).isPointer() || + MRI.getType(I.getOperand(1).getReg()).isPointer()) + return selectCopy(I, TII, MRI, TRI, RBI); case TargetOpcode::G_BITCAST: - return selectCopy(I, TII, MRI, TRI, RBI); + // Imported SelectionDAG rules can handle every bitcast except those that + // bitcast from a type to the same type. Ideally, these shouldn't occur + // but we might not run an optimizer that deletes them. + if (MRI.getType(I.getOperand(0).getReg()) == + MRI.getType(I.getOperand(1).getReg())) + return selectCopy(I, TII, MRI, TRI, RBI); case TargetOpcode::G_FPEXT: { if (MRI.getType(I.getOperand(0).getReg()) != LLT::scalar(64)) { Index: utils/TableGen/GlobalISelEmitter.cpp =================================================================== --- utils/TableGen/GlobalISelEmitter.cpp +++ utils/TableGen/GlobalISelEmitter.cpp @@ -2270,6 +2270,7 @@ auto &DstMIBuilder = M.addAction(0, &DstI, InsnMatcher); DstMIBuilder.addRenderer(0, InsnMatcher, DstIOperand.Name); DstMIBuilder.addRenderer(0, InsnMatcher, Dst->getName()); + M.addAction(0, 0, RC); // We're done with this pattern! It's eligible for GISel emission; return // it.