Skip to content

Commit 7915444

Browse files
committed
Revert "[AArch64][GlobalISel] Add post-legalize combine for sext_inreg(trunc(sextload)) -> copy"
This reverts commit 64eb3a4. It caused miscompiles with optimizations enabled. Reverting while I investigate.
1 parent f1ae96d commit 7915444

File tree

6 files changed

+1
-120
lines changed

6 files changed

+1
-120
lines changed

llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@ class CombinerHelper {
107107
bool matchCombineIndexedLoadStore(MachineInstr &MI, IndexedLoadStoreMatchInfo &MatchInfo);
108108
void applyCombineIndexedLoadStore(MachineInstr &MI, IndexedLoadStoreMatchInfo &MatchInfo);
109109

110-
bool matchSextAlreadyExtended(MachineInstr &MI);
111-
bool applySextAlreadyExtended(MachineInstr &MI);
112-
113110
bool matchElideBrByInvertingCond(MachineInstr &MI);
114111
void applyElideBrByInvertingCond(MachineInstr &MI);
115112
bool tryElideBrByInvertingCond(MachineInstr &MI);

llvm/include/llvm/Target/GlobalISel/Combine.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,6 @@ def extending_loads : GICombineRule<
125125
(apply [{ Helper.applyCombineExtendingLoads(*${root}, ${matchinfo}); }])>;
126126
def combines_for_extload: GICombineGroup<[extending_loads]>;
127127

128-
def sext_already_extended : GICombineRule<
129-
(defs root:$d),
130-
(match (wip_match_opcode G_SEXT_INREG):$d,
131-
[{ return Helper.matchSextAlreadyExtended(*${d}); }]),
132-
(apply [{ Helper.applySextAlreadyExtended(*${d}); }])>;
133-
134128
def combine_indexed_load_store : GICombineRule<
135129
(defs root:$root, indexed_load_store_matchdata:$matchinfo),
136130
(match (wip_match_opcode G_LOAD, G_SEXTLOAD, G_ZEXTLOAD, G_STORE):$root,

llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -576,24 +576,6 @@ bool CombinerHelper::dominates(const MachineInstr &DefMI,
576576
return isPredecessor(DefMI, UseMI);
577577
}
578578

579-
bool CombinerHelper::matchSextAlreadyExtended(MachineInstr &MI) {
580-
assert(MI.getOpcode() == TargetOpcode::G_SEXT_INREG);
581-
Register SrcReg = MI.getOperand(1).getReg();
582-
unsigned SrcSignBits = KB->computeNumSignBits(SrcReg);
583-
unsigned NumSextBits =
584-
MRI.getType(MI.getOperand(0).getReg()).getScalarSizeInBits() -
585-
MI.getOperand(2).getImm();
586-
return SrcSignBits >= NumSextBits;
587-
}
588-
589-
bool CombinerHelper::applySextAlreadyExtended(MachineInstr &MI) {
590-
assert(MI.getOpcode() == TargetOpcode::G_SEXT_INREG);
591-
MachineIRBuilder MIB(MI);
592-
MIB.buildCopy(MI.getOperand(0).getReg(), MI.getOperand(1).getReg());
593-
MI.eraseFromParent();
594-
return true;
595-
}
596-
597579
bool CombinerHelper::findPostIndexCandidate(MachineInstr &MI, Register &Addr,
598580
Register &Base, Register &Offset) {
599581
auto &MF = *MI.getParent()->getParent();

llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//
1212
//===------------------
1313
#include "llvm/CodeGen/GlobalISel/GISelKnownBits.h"
14-
#include "llvm/Analysis/TargetTransformInfo.h"
1514
#include "llvm/Analysis/ValueTracking.h"
1615
#include "llvm/CodeGen/GlobalISel/Utils.h"
1716
#include "llvm/CodeGen/MachineFrameInfo.h"
@@ -442,16 +441,6 @@ unsigned GISelKnownBits::computeNumSignBits(Register R,
442441
unsigned Tmp = DstTy.getScalarSizeInBits() - SrcTy.getScalarSizeInBits();
443442
return computeNumSignBits(Src, DemandedElts, Depth + 1) + Tmp;
444443
}
445-
case TargetOpcode::G_SEXTLOAD: {
446-
Register Dst = MI.getOperand(0).getReg();
447-
LLT Ty = MRI.getType(Dst);
448-
// TODO: add vector support
449-
if (Ty.isVector())
450-
break;
451-
if (MI.hasOneMemOperand())
452-
return Ty.getSizeInBits() - (*MI.memoperands_begin())->getSizeInBits();
453-
break;
454-
}
455444
case TargetOpcode::G_TRUNC: {
456445
Register Src = MI.getOperand(1).getReg();
457446
LLT SrcTy = MRI.getType(Src);

llvm/lib/Target/AArch64/AArch64Combine.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ def shuffle_vector_pseudos : GICombineGroup<[dup, rev, ext, zip, uzp, trn]>;
7979
def AArch64PostLegalizerCombinerHelper
8080
: GICombinerHelper<"AArch64GenPostLegalizerCombinerHelper",
8181
[erase_undef_store, combines_for_extload,
82-
sext_already_extended, shuffle_vector_pseudos]> {
82+
shuffle_vector_pseudos]> {
8383
let DisableRuleOption = "aarch64postlegalizercombiner-disable-rule";
8484
}

llvm/test/CodeGen/AArch64/GlobalISel/combine-sext-trunc-sextload.mir

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)