1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

Revert "[GlobalISel] Add scalar widening for G_MERGE_VALUES destination"

This reverts commit 0a37163d1d855a2db41e1f46ddbc3f4570bd7ca6.

Reason: Broke the sanitizer msan bots. More details are available in the
original Phabricator review: https://reviews.llvm.org/D106814.
This commit is contained in:
Mitch Phillips 2021-07-26 19:32:49 -07:00
parent 14491b35e0
commit fcd0279b17
3 changed files with 8 additions and 168 deletions

View File

@ -165,10 +165,8 @@ public:
Register widenWithUnmerge(LLT WideTy, Register OrigReg); Register widenWithUnmerge(LLT WideTy, Register OrigReg);
private: private:
LegalizeResult widenScalarSrcMergeValues(MachineInstr &MI, LLT WideTy); LegalizeResult
LegalizeResult widenScalarDstMergeValues(MachineInstr &MI, LLT WideTy); widenScalarMergeValues(MachineInstr &MI, unsigned TypeIdx, LLT WideTy);
LegalizeResult widenScalarMergeValues(MachineInstr &MI, unsigned TypeIdx,
LLT WideTy);
LegalizeResult LegalizeResult
widenScalarUnmergeValues(MachineInstr &MI, unsigned TypeIdx, LLT WideTy); widenScalarUnmergeValues(MachineInstr &MI, unsigned TypeIdx, LLT WideTy);
LegalizeResult LegalizeResult

View File

@ -1418,7 +1418,11 @@ void LegalizerHelper::bitcastDst(MachineInstr &MI, LLT CastTy, unsigned OpIdx) {
} }
LegalizerHelper::LegalizeResult LegalizerHelper::LegalizeResult
LegalizerHelper::widenScalarSrcMergeValues(MachineInstr &MI, LLT WideTy) { LegalizerHelper::widenScalarMergeValues(MachineInstr &MI, unsigned TypeIdx,
LLT WideTy) {
if (TypeIdx != 1)
return UnableToLegalize;
Register DstReg = MI.getOperand(0).getReg(); Register DstReg = MI.getOperand(0).getReg();
LLT DstTy = MRI.getType(DstReg); LLT DstTy = MRI.getType(DstReg);
if (DstTy.isVector()) if (DstTy.isVector())
@ -1535,44 +1539,6 @@ LegalizerHelper::widenScalarSrcMergeValues(MachineInstr &MI, LLT WideTy) {
return Legalized; return Legalized;
} }
LegalizerHelper::LegalizeResult
LegalizerHelper::widenScalarDstMergeValues(MachineInstr &MI, LLT WideTy) {
// Disallow for vectors and pointers. Not sure about what to do with pointers.
LLT DstTy = MRI.getType(MI.getOperand(0).getReg());
if (!DstTy.isScalar())
return UnableToLegalize;
LLT SrcTy = MRI.getType(MI.getOperand(1).getReg());
const int DstSize = DstTy.getSizeInBits();
const int SrcSize = SrcTy.getSizeInBits();
const int WideSize = WideTy.getSizeInBits();
// If WideSize = DstSize + K * SrcSize then we can get WideSize by padding
// with K undef elements.
//
// dst = G_MERGE_VALUES elt1, elt2, ..., eltN
// -> wide_dst = G_MERGE_VALUES elt1, elt2, ... eltN, pad1, pad2, ... padK
int Difference = WideSize - DstSize;
if ((Difference) % SrcSize != 0)
return UnableToLegalize;
int NumPadEltsToAdd = Difference / SrcSize;
assert(NumPadEltsToAdd && "Expected to add at least one element?");
MachineFunction &MF = *MI.getMF();
for (int I = 0; I < NumPadEltsToAdd; ++I) {
auto PadElt = MIRBuilder.buildUndef(SrcTy);
MI.addOperand(
MF, MachineOperand::CreateReg(PadElt.getReg(0), /*isDef = */ false));
}
widenScalarDst(MI, WideTy, 0);
return Legalized;
}
LegalizerHelper::LegalizeResult
LegalizerHelper::widenScalarMergeValues(MachineInstr &MI, unsigned TypeIdx,
LLT WideTy) {
if (TypeIdx == 0)
return widenScalarDstMergeValues(MI, WideTy);
return widenScalarSrcMergeValues(MI, WideTy);
}
Register LegalizerHelper::widenWithUnmerge(LLT WideTy, Register OrigReg) { Register LegalizerHelper::widenWithUnmerge(LLT WideTy, Register OrigReg) {
Register WideReg = MRI.createGenericVirtualRegister(WideTy); Register WideReg = MRI.createGenericVirtualRegister(WideTy);
LLT OrigTy = MRI.getType(OrigReg); LLT OrigTy = MRI.getType(OrigReg);

View File

@ -1,5 +1,5 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -march=aarch64 -O0 -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s # RUN: llc -march=aarch64 -O0 -run-pass=legalizer %s -o - | FileCheck %s
--- ---
name: test_merge_s4 name: test_merge_s4
@ -26,127 +26,3 @@ body: |
%4:_(s64) = G_ANYEXT %3 %4:_(s64) = G_ANYEXT %3
$x0 = COPY %4 $x0 = COPY %4
... ...
---
name: test_merge_s24_s8
tracksRegLiveness: true
body: |
bb.0:
liveins: $w0
; 24 + 8 = 32 => Add 1 undef element as padding.
; CHECK-LABEL: name: test_merge_s24_s8
; CHECK: liveins: $w0
; CHECK: %x:_(s8) = G_CONSTANT i8 0
; CHECK: [[DEF:%[0-9]+]]:_(s8) = G_IMPLICIT_DEF
; CHECK: [[MV:%[0-9]+]]:_(s32) = G_MERGE_VALUES %x(s8), %x(s8), %x(s8), [[DEF]](s8)
; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16777215
; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY [[MV]](s32)
; CHECK: %zext:_(s32) = G_AND [[COPY]], [[C]]
; CHECK: $w0 = COPY %zext(s32)
; CHECK: RET_ReallyLR implicit $w0
%x:_(s8) = G_CONSTANT i8 0
%merge:_(s24) = G_MERGE_VALUES %x, %x, %x
%zext:_(s32) = G_ZEXT %merge
$w0 = COPY %zext
RET_ReallyLR implicit $w0
...
---
name: test_merge_s40_s8
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; 64 - 40 = 24; 24 / 8 = 3 => Add 3 undef elements as padding.
; CHECK-LABEL: name: test_merge_s40_s8
; CHECK: liveins: $x0
; CHECK: %x:_(s8) = G_CONSTANT i8 0
; CHECK: [[DEF:%[0-9]+]]:_(s8) = G_IMPLICIT_DEF
; CHECK: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES %x(s8), %x(s8), %x(s8), %x(s8), %x(s8), [[DEF]](s8), [[DEF]](s8), [[DEF]](s8)
; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1099511627775
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY [[MV]](s64)
; CHECK: %zext:_(s64) = G_AND [[COPY]], [[C]]
; CHECK: $x0 = COPY %zext(s64)
; CHECK: RET_ReallyLR implicit $x0
%x:_(s8) = G_CONSTANT i8 0
%merge:_(s40) = G_MERGE_VALUES %x, %x, %x, %x, %x
%zext:_(s64) = G_ZEXT %merge
$x0 = COPY %zext
RET_ReallyLR implicit $x0
...
---
name: test_merge_s7_s1
tracksRegLiveness: true
body: |
bb.0:
liveins: $w0
; 7 + 1 = 8 -> Add one undef.
; CHECK-LABEL: name: test_merge_s7_s1
; CHECK: liveins: $w0
; CHECK: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 0
; CHECK: %x:_(s1) = G_TRUNC [[C]](s8)
; CHECK: [[DEF:%[0-9]+]]:_(s1) = G_IMPLICIT_DEF
; CHECK: [[MV:%[0-9]+]]:_(s8) = G_MERGE_VALUES %x(s1), %x(s1), %x(s1), %x(s1), %x(s1), %x(s1), %x(s1), [[DEF]](s1)
; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 127
; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[MV]](s8)
; CHECK: %zext:_(s32) = G_AND [[ANYEXT]], [[C1]]
; CHECK: $w0 = COPY %zext(s32)
; CHECK: RET_ReallyLR implicit $w0
%x:_(s1) = G_CONSTANT i1 0
%merge:_(s7) = G_MERGE_VALUES %x, %x, %x, %x, %x, %x, %x
%zext:_(s32) = G_ZEXT %merge
$w0 = COPY %zext
RET_ReallyLR implicit $w0
...
---
name: test_merge_s21_s7
tracksRegLiveness: true
body: |
bb.0:
liveins: $w0
; Can't legalize this one yet.
; CHECK-LABEL: name: test_merge_s21_s7
; CHECK: liveins: $w0
; CHECK: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 0
; CHECK: %x:_(s7) = G_TRUNC [[C]](s8)
; CHECK: %merge:_(s21) = G_MERGE_VALUES %x(s7), %x(s7), %x(s7)
; CHECK: %zext:_(s32) = G_ZEXT %merge(s21)
; CHECK: $w0 = COPY %zext(s32)
; CHECK: RET_ReallyLR implicit $w0
%x:_(s7) = G_CONSTANT i7 0
%merge:_(s21) = G_MERGE_VALUES %x, %x, %x
%zext:_(s32) = G_ZEXT %merge
$w0 = COPY %zext
RET_ReallyLR implicit $w0
...
---
name: test_merge_s11_s1
tracksRegLiveness: true
body: |
bb.0:
liveins: $w0
; 7 + 1 = 8 -> Add one undef.
; CHECK-LABEL: name: test_merge_s11_s1
; CHECK: liveins: $w0
; CHECK: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 0
; CHECK: %x:_(s1) = G_TRUNC [[C]](s8)
; CHECK: [[DEF:%[0-9]+]]:_(s1) = G_IMPLICIT_DEF
; CHECK: [[MV:%[0-9]+]]:_(s16) = G_MERGE_VALUES %x(s1), %x(s1), %x(s1), %x(s1), %x(s1), %x(s1), %x(s1), %x(s1), %x(s1), %x(s1), %x(s1), [[DEF]](s1), [[DEF]](s1), [[DEF]](s1), [[DEF]](s1), [[DEF]](s1)
; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 2047
; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[MV]](s16)
; CHECK: %zext:_(s32) = G_AND [[ANYEXT]], [[C1]]
; CHECK: $w0 = COPY %zext(s32)
; CHECK: RET_ReallyLR implicit $w0
%x:_(s1) = G_CONSTANT i1 0
%merge:_(s11) = G_MERGE_VALUES %x, %x, %x, %x, %x, %x, %x, %x, %x, %x, %x
%zext:_(s32) = G_ZEXT %merge
$w0 = COPY %zext
RET_ReallyLR implicit $w0