50 Commits

Author SHA1 Message Date
Jay Foad
d6fc7d3ab1 Fix typo "intead" 2024-11-21 14:48:38 +00:00
Csanád Hajdú
72901fe19e
[AArch64] Fold UBFMXri to UBFMWri when it's an LSR or LSL alias (#106968)
Using the LSR or LSL aliases of UBFM can be faster on some CPUs, so it
is worth changing 64 bit UBFM instructions, that are equivalent to 32
bit LSR/LSL operations, to 32 bit variants.

This change folds the following patterns:
* If `Imms == 31` and `Immr <= Imms`:
   `UBFMXri %0, Immr, Imms`  ->  `UBFMWri %0.sub_32, Immr, Imms`
* If `Immr == Imms + 33`:
   `UBFMXri %0, Immr, Imms`  ->  `UBFMWri %0.sub_32, Immr - 32, Imms`
2024-09-17 11:21:23 +01:00
David Green
fe946bfb72
[AArch64] Extend sxtw peephole to uxtw. (#104516)
This extends the existing sxtw peephole optimization (#96293) to uxtw,
which in llvm is a ORRWrr which clears the top bits.

Fixes #98481
2024-08-20 14:46:19 +01:00
Marina Taylor
29763aa471
[AArch64] Peephole optimization to remove redundant csel instructions (#101483)
Given a sequence such as

  %8:gpr64 = COPY $xzr
  %10:gpr64 = COPY $xzr
  %11:gpr64 = CSELXr %8:gpr64, %10:gpr64, 0, implicit $nzcv

`PeepholeOptimizer::foldRedundantCopy` led to the creation of select
instructions where both inputs were the same register:

  %11:gpr64 = CSELXr %8:gpr64, %8:gpr64, 0, implicit $nzcv

This change adds a later peephole optimization that replaces such
selects with unconditional moves.
2024-08-05 11:34:59 +01:00
David Green
c7c5e05389 [AArch64] Format comment to fit into line-length. NFC 2024-08-01 17:46:39 +01:00
David Green
600d493752 [AArch64] Remove superfluous sxtw in peephole opt (#96293)
Across a basic-block we might have an i32 extract from a value that only
operates on upper bits (for example a sxtw). We can replace the COPY
with a new version skipping the sxtw.

This is a re-commit of 7f2a5dfe35f8bbaca2819644c7aa844f938befd6, with a fix for
removing all the intermediate COPY nodes (and some extra debug logging).
2024-07-19 16:51:28 +01:00
Krasimir Georgiev
290184880a Revert "[AArch64] Remove superfluous sxtw in peephole opt (#96293)"
This reverts commit 7f2a5dfe35f8bbaca2819644c7aa844f938befd6.

It appears that after this, llc segfaults on the following code:
```
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32"
target triple = "aarch64--linux-eabi"

define i32 @f(i32 %0) {
entry:
  %1 = sext i32 %0 to i64
  br label %A

A:
  %2 = trunc i64 %1 to i32
  %a69.us = sub i32 0, %2
  %a69.us.fr = freeze i32 %a69.us
  %3 = zext i32 %a69.us.fr to i64
  br label %B

B:
  %t = icmp eq i64 0, %3
  br i1 %t, label %A, label %B
}
```

assert.h assertion failed at .../llvm/lib/CodeGen/LiveVariables.cpp:159 in void llvm::LiveVariables::HandleVirtRegUse(Register, MachineBasicBlock *, MachineInstr &): MRI->getVRegDef(Reg) && "Register use before def!"
2024-07-17 10:53:25 +00:00
David Green
7f2a5dfe35
[AArch64] Remove superfluous sxtw in peephole opt (#96293)
Across a basic-block we might have in i32 extract from a value that only
operates on upper bits (for example a sxtw). We can replace the COPY
with a new version skipping the sxtw.
2024-07-11 20:19:39 +01:00
paperchalice
79d0de2ac3
[CodeGen][NewPM] Port machine-loops to new pass manager (#97793)
- Add `MachineLoopAnalysis`.
- Add `MachineLoopPrinterPass`.
- Convert to `MachineLoopInfoWrapperPass` in legacy pass manager.
2024-07-09 09:11:18 +08:00
David Green
36e74cfdbd
[AArch64] Clear kill flags when removing FMOVDr. (#86308)
The uses of OldDef/NewDef may not be killed in the same place they
previously were after they are replaced, and so need to be cleared.
2024-03-27 18:36:02 +00:00
David Green
f42e321b9f
[AArch64] Use FMOVDr for clearing upper bits (#83107)
This adds some tablegen patterns for generating FMOVDr from concat(X,
zeroes), as the FMOV will implicitly zero the upper bits of the
register. An extra AArch64MIPeepholeOpt is needed to make sure we can
remove the FMOV in the same way we would remove the insert code.
2024-02-27 19:45:43 +00:00
David Green
86780f49ef [AArch64] Fix order of isReg and isDef checks in INSvi64 peephole.
The isDef asserts that the operand isReg, so the checks need to happen in the
other order.
2023-07-12 09:51:28 +01:00
David Green
44479b80a6 [AArch64] Ensure constrained register class in INS peephole.
Ensure we constrain the register class of the NewDef to that of OldDef, in case
they do not match.

Fixes #63777
2023-07-10 22:48:10 +01:00
David Green
04e94bb12f [AArch64] Update Changed status in AArch64MIPeepholeOpt
I have not seen this be a problem, but the Changed status should be updated not
reset on new instruction to get the total Changed status overall.
2023-05-11 19:55:44 +01:00
David Green
6e7840dd42 [AArch64] Extend fp64 top zeroing peephole to all instructions
D147235 added a fold to remove instructions that zero the upper half of a
register if the instruction already implicitly zeros the register. As far as I
can tell this applies to all instructions that define a FPR64 register in
AArch64. This patch switches to a check for the register class. The full list
of instructions is:
  BSPv8i8
  FMOVD0
  ABSv1i64
  ABSv2i32
  ABSv4i16
  ABSv8i8
  ADDHNv2i64_v2i32
  ADDHNv4i32_v4i16
  ADDHNv8i16_v8i8
  ADDPv2i32
  ADDPv2i64p
  ADDPv4i16
  ADDPv8i8
  ADDv1i64
  ADDv2i32
  ADDv4i16
  ADDv8i8
  ANDv8i8
  BF16DOTlanev4bf16
  BFDOTv4bf16
  BICv2i32
  BICv4i16
  BICv8i8
  BIFv8i8
  BITv8i8
  BSLv8i8
  CLASTA_VPZ_D
  CLASTB_VPZ_D
  CLSv2i32
  CLSv4i16
  CLSv8i8
  CLZv2i32
  CLZv4i16
  CLZv8i8
  CMEQv1i64
  CMEQv1i64rz
  CMEQv2i32
  CMEQv2i32rz
  CMEQv4i16
  CMEQv4i16rz
  CMEQv8i8
  CMEQv8i8rz
  CMGEv1i64
  CMGEv1i64rz
  CMGEv2i32
  CMGEv2i32rz
  CMGEv4i16
  CMGEv4i16rz
  CMGEv8i8
  CMGEv8i8rz
  CMGTv1i64
  CMGTv1i64rz
  CMGTv2i32
  CMGTv2i32rz
  CMGTv4i16
  CMGTv4i16rz
  CMGTv8i8
  CMGTv8i8rz
  CMHIv1i64
  CMHIv2i32
  CMHIv4i16
  CMHIv8i8
  CMHSv1i64
  CMHSv2i32
  CMHSv4i16
  CMHSv8i8
  CMLEv1i64rz
  CMLEv2i32rz
  CMLEv4i16rz
  CMLEv8i8rz
  CMLTv1i64rz
  CMLTv2i32rz
  CMLTv4i16rz
  CMLTv8i8rz
  CMTSTv1i64
  CMTSTv2i32
  CMTSTv4i16
  CMTSTv8i8
  CNTv8i8
  DUPi64
  DUPv2i32gpr
  DUPv2i32lane
  DUPv4i16gpr
  DUPv4i16lane
  DUPv8i8gpr
  DUPv8i8lane
  EORv8i8
  EXTv8i8
  FABD64
  FABDv2f32
  FABDv4f16
  FABSDr
  FABSv2f32
  FABSv4f16
  FACGE64
  FACGEv2f32
  FACGEv4f16
  FACGT64
  FACGTv2f32
  FACGTv4f16
  FADDDrr
  FADDPv2f32
  FADDPv2i64p
  FADDPv4f16
  FADDv2f32
  FADDv4f16
  FCADDv2f32
  FCADDv4f16
  FCMEQ64
  FCMEQv1i64rz
  FCMEQv2f32
  FCMEQv2i32rz
  FCMEQv4f16
  FCMEQv4i16rz
  FCMGE64
  FCMGEv1i64rz
  FCMGEv2f32
  FCMGEv2i32rz
  FCMGEv4f16
  FCMGEv4i16rz
  FCMGT64
  FCMGTv1i64rz
  FCMGTv2f32
  FCMGTv2i32rz
  FCMGTv4f16
  FCMGTv4i16rz
  FCMLAv2f32
  FCMLAv4f16
  FCMLAv4f16_indexed
  FCMLEv1i64rz
  FCMLEv2i32rz
  FCMLEv4i16rz
  FCMLTv1i64rz
  FCMLTv2i32rz
  FCMLTv4i16rz
  FCSELDrrr
  FCVTASv1i64
  FCVTASv2f32
  FCVTASv4f16
  FCVTAUv1i64
  FCVTAUv2f32
  FCVTAUv4f16
  FCVTDHr
  FCVTDSr
  FCVTMSv1i64
  FCVTMSv2f32
  FCVTMSv4f16
  FCVTMUv1i64
  FCVTMUv2f32
  FCVTMUv4f16
  FCVTNSv1i64
  FCVTNSv2f32
  FCVTNSv4f16
  FCVTNUv1i64
  FCVTNUv2f32
  FCVTNUv4f16
  FCVTNv2i32
  FCVTNv4i16
  FCVTPSv1i64
  FCVTPSv2f32
  FCVTPSv4f16
  FCVTPUv1i64
  FCVTPUv2f32
  FCVTPUv4f16
  FCVTXNv2f32
  FCVTZSd
  FCVTZSv1i64
  FCVTZSv2f32
  FCVTZSv2i32_shift
  FCVTZSv4f16
  FCVTZSv4i16_shift
  FCVTZUd
  FCVTZUv1i64
  FCVTZUv2f32
  FCVTZUv2i32_shift
  FCVTZUv4f16
  FCVTZUv4i16_shift
  FDIVDrr
  FDIVv2f32
  FDIVv4f16
  FMADDDrrr
  FMAXDrr
  FMAXNMDrr
  FMAXNMPv2f32
  FMAXNMPv2i64p
  FMAXNMPv4f16
  FMAXNMv2f32
  FMAXNMv4f16
  FMAXPv2f32
  FMAXPv2i64p
  FMAXPv4f16
  FMAXv2f32
  FMAXv4f16
  FMINDrr
  FMINNMDrr
  FMINNMPv2f32
  FMINNMPv2i64p
  FMINNMPv4f16
  FMINNMv2f32
  FMINNMv4f16
  FMINPv2f32
  FMINPv2i64p
  FMINPv4f16
  FMINv2f32
  FMINv4f16
  FMLAL2lanev4f16
  FMLAL2v4f16
  FMLALlanev4f16
  FMLALv4f16
  FMLAv1i64_indexed
  FMLAv2f32
  FMLAv2i32_indexed
  FMLAv4f16
  FMLAv4i16_indexed
  FMLSL2lanev4f16
  FMLSL2v4f16
  FMLSLlanev4f16
  FMLSLv4f16
  FMLSv1i64_indexed
  FMLSv2f32
  FMLSv2i32_indexed
  FMLSv4f16
  FMLSv4i16_indexed
  FMOVDi
  FMOVDr
  FMOVXDr
  FMOVv2f32_ns
  FMOVv4f16_ns
  FMSUBDrrr
  FMULDrr
  FMULX64
  FMULXv1i64_indexed
  FMULXv2f32
  FMULXv2i32_indexed
  FMULXv4f16
  FMULXv4i16_indexed
  FMULv1i64_indexed
  FMULv2f32
  FMULv2i32_indexed
  FMULv4f16
  FMULv4i16_indexed
  FNEGDr
  FNEGv2f32
  FNEGv4f16
  FNMADDDrrr
  FNMSUBDrrr
  FNMULDrr
  FRECPEv1i64
  FRECPEv2f32
  FRECPEv4f16
  FRECPS64
  FRECPSv2f32
  FRECPSv4f16
  FRECPXv1i64
  FRINT32XDr
  FRINT32Xv2f32
  FRINT32ZDr
  FRINT32Zv2f32
  FRINT64XDr
  FRINT64Xv2f32
  FRINT64ZDr
  FRINT64Zv2f32
  FRINTADr
  FRINTAv2f32
  FRINTAv4f16
  FRINTIDr
  FRINTIv2f32
  FRINTIv4f16
  FRINTMDr
  FRINTMv2f32
  FRINTMv4f16
  FRINTNDr
  FRINTNv2f32
  FRINTNv4f16
  FRINTPDr
  FRINTPv2f32
  FRINTPv4f16
  FRINTXDr
  FRINTXv2f32
  FRINTXv4f16
  FRINTZDr
  FRINTZv2f32
  FRINTZv4f16
  FRSQRTEv1i64
  FRSQRTEv2f32
  FRSQRTEv4f16
  FRSQRTS64
  FRSQRTSv2f32
  FRSQRTSv4f16
  FSQRTDr
  FSQRTv2f32
  FSQRTv4f16
  FSUBDrr
  FSUBv2f32
  FSUBv4f16
  LASTA_VPZ_D
  LASTB_VPZ_D
  LD1Onev1d
  LD1Onev2s
  LD1Onev4h
  LD1Onev8b
  LD1Rv1d
  LD1Rv2s
  LD1Rv4h
  LD1Rv8b
  LDAPURdi
  LDNPDi
  LDPDi
  LDRDl
  LDRDroW
  LDRDroX
  LDRDui
  LDURDi
  MLAv2i32
  MLAv2i32_indexed
  MLAv4i16
  MLAv4i16_indexed
  MLAv8i8
  MLSv2i32
  MLSv2i32_indexed
  MLSv4i16
  MLSv4i16_indexed
  MLSv8i8
  MOVID
  MOVIv2i32
  MOVIv2s_msl
  MOVIv4i16
  MOVIv8b_ns
  MULv2i32
  MULv2i32_indexed
  MULv4i16
  MULv4i16_indexed
  MULv8i8
  MVNIv2i32
  MVNIv2s_msl
  MVNIv4i16
  NEGv1i64
  NEGv2i32
  NEGv4i16
  NEGv8i8
  NOTv8i8
  ORNv8i8
  ORRv2i32
  ORRv4i16
  ORRv8i8
  PMULv8i8
  RADDHNv2i64_v2i32
  RADDHNv4i32_v4i16
  RADDHNv8i16_v8i8
  RBITv8i8
  REV16v8i8
  REV32v4i16
  REV32v8i8
  REV64v2i32
  REV64v4i16
  REV64v8i8
  RSHRNv2i32_shift
  RSHRNv4i16_shift
  RSHRNv8i8_shift
  RSUBHNv2i64_v2i32
  RSUBHNv4i32_v4i16
  RSUBHNv8i16_v8i8
  SABAv2i32
  SABAv4i16
  SABAv8i8
  SABDv2i32
  SABDv4i16
  SABDv8i8
  SADALPv2i32_v1i64
  SADALPv4i16_v2i32
  SADALPv8i8_v4i16
  SADDLPv2i32_v1i64
  SADDLPv4i16_v2i32
  SADDLPv8i8_v4i16
  SADDLVv4i32v
  SCVTFSWDri
  SCVTFSXDri
  SCVTFUWDri
  SCVTFUXDri
  SCVTFd
  SCVTFv1i64
  SCVTFv2f32
  SCVTFv2i32_shift
  SCVTFv4f16
  SCVTFv4i16_shift
  SDOTlanev8i8
  SDOTv8i8
  SHADDv2i32
  SHADDv4i16
  SHADDv8i8
  SHLd
  SHLv2i32_shift
  SHLv4i16_shift
  SHLv8i8_shift
  SHRNv2i32_shift
  SHRNv4i16_shift
  SHRNv8i8_shift
  SHSUBv2i32
  SHSUBv4i16
  SHSUBv8i8
  SLId
  SLIv2i32_shift
  SLIv4i16_shift
  SLIv8i8_shift
  SMAXPv2i32
  SMAXPv4i16
  SMAXPv8i8
  SMAXv2i32
  SMAXv4i16
  SMAXv8i8
  SMINPv2i32
  SMINPv4i16
  SMINPv8i8
  SMINv2i32
  SMINv4i16
  SMINv8i8
  SQABSv1i64
  SQABSv2i32
  SQABSv4i16
  SQABSv8i8
  SQADDv1i64
  SQADDv2i32
  SQADDv4i16
  SQADDv8i8
  SQDMLALi32
  SQDMLALv1i64_indexed
  SQDMLSLi32
  SQDMLSLv1i64_indexed
  SQDMULHv2i32
  SQDMULHv2i32_indexed
  SQDMULHv4i16
  SQDMULHv4i16_indexed
  SQDMULLi32
  SQDMULLv1i64_indexed
  SQNEGv1i64
  SQNEGv2i32
  SQNEGv4i16
  SQNEGv8i8
  SQRDMLAHv2i32
  SQRDMLAHv2i32_indexed
  SQRDMLAHv4i16
  SQRDMLAHv4i16_indexed
  SQRDMLSHv2i32
  SQRDMLSHv2i32_indexed
  SQRDMLSHv4i16
  SQRDMLSHv4i16_indexed
  SQRDMULHv2i32
  SQRDMULHv2i32_indexed
  SQRDMULHv4i16
  SQRDMULHv4i16_indexed
  SQRSHLv1i64
  SQRSHLv2i32
  SQRSHLv4i16
  SQRSHLv8i8
  SQRSHRNv2i32_shift
  SQRSHRNv4i16_shift
  SQRSHRNv8i8_shift
  SQRSHRUNv2i32_shift
  SQRSHRUNv4i16_shift
  SQRSHRUNv8i8_shift
  SQSHLUd
  SQSHLUv2i32_shift
  SQSHLUv4i16_shift
  SQSHLUv8i8_shift
  SQSHLd
  SQSHLv1i64
  SQSHLv2i32
  SQSHLv2i32_shift
  SQSHLv4i16
  SQSHLv4i16_shift
  SQSHLv8i8
  SQSHLv8i8_shift
  SQSHRNv2i32_shift
  SQSHRNv4i16_shift
  SQSHRNv8i8_shift
  SQSHRUNv2i32_shift
  SQSHRUNv4i16_shift
  SQSHRUNv8i8_shift
  SQSUBv1i64
  SQSUBv2i32
  SQSUBv4i16
  SQSUBv8i8
  SQXTNv2i32
  SQXTNv4i16
  SQXTNv8i8
  SQXTUNv2i32
  SQXTUNv4i16
  SQXTUNv8i8
  SRHADDv2i32
  SRHADDv4i16
  SRHADDv8i8
  SRId
  SRIv2i32_shift
  SRIv4i16_shift
  SRIv8i8_shift
  SRSHLv1i64
  SRSHLv2i32
  SRSHLv4i16
  SRSHLv8i8
  SRSHRd
  SRSHRv2i32_shift
  SRSHRv4i16_shift
  SRSHRv8i8_shift
  SRSRAd
  SRSRAv2i32_shift
  SRSRAv4i16_shift
  SRSRAv8i8_shift
  SSHLv1i64
  SSHLv2i32
  SSHLv4i16
  SSHLv8i8
  SSHRd
  SSHRv2i32_shift
  SSHRv4i16_shift
  SSHRv8i8_shift
  SSRAd
  SSRAv2i32_shift
  SSRAv4i16_shift
  SSRAv8i8_shift
  SUBHNv2i64_v2i32
  SUBHNv4i32_v4i16
  SUBHNv8i16_v8i8
  SUBv1i64
  SUBv2i32
  SUBv4i16
  SUBv8i8
  SUDOTlanev8i8
  SUQADDv1i64
  SUQADDv2i32
  SUQADDv4i16
  SUQADDv8i8
  TBLv8i8Four
  TBLv8i8One
  TBLv8i8Three
  TBLv8i8Two
  TBXv8i8Four
  TBXv8i8One
  TBXv8i8Three
  TBXv8i8Two
  TRN1v2i32
  TRN1v4i16
  TRN1v8i8
  TRN2v2i32
  TRN2v4i16
  TRN2v8i8
  UABAv2i32
  UABAv4i16
  UABAv8i8
  UABDv2i32
  UABDv4i16
  UABDv8i8
  UADALPv2i32_v1i64
  UADALPv4i16_v2i32
  UADALPv8i8_v4i16
  UADDLPv2i32_v1i64
  UADDLPv4i16_v2i32
  UADDLPv8i8_v4i16
  UADDLVv4i32v
  UCVTFSWDri
  UCVTFSXDri
  UCVTFUWDri
  UCVTFUXDri
  UCVTFd
  UCVTFv1i64
  UCVTFv2f32
  UCVTFv2i32_shift
  UCVTFv4f16
  UCVTFv4i16_shift
  UDOTlanev8i8
  UDOTv8i8
  UHADDv2i32
  UHADDv4i16
  UHADDv8i8
  UHSUBv2i32
  UHSUBv4i16
  UHSUBv8i8
  UMAXPv2i32
  UMAXPv4i16
  UMAXPv8i8
  UMAXv2i32
  UMAXv4i16
  UMAXv8i8
  UMINPv2i32
  UMINPv4i16
  UMINPv8i8
  UMINv2i32
  UMINv4i16
  UMINv8i8
  UQADDv1i64
  UQADDv2i32
  UQADDv4i16
  UQADDv8i8
  UQRSHLv1i64
  UQRSHLv2i32
  UQRSHLv4i16
  UQRSHLv8i8
  UQRSHRNv2i32_shift
  UQRSHRNv4i16_shift
  UQRSHRNv8i8_shift
  UQSHLd
  UQSHLv1i64
  UQSHLv2i32
  UQSHLv2i32_shift
  UQSHLv4i16
  UQSHLv4i16_shift
  UQSHLv8i8
  UQSHLv8i8_shift
  UQSHRNv2i32_shift
  UQSHRNv4i16_shift
  UQSHRNv8i8_shift
  UQSUBv1i64
  UQSUBv2i32
  UQSUBv4i16
  UQSUBv8i8
  UQXTNv2i32
  UQXTNv4i16
  UQXTNv8i8
  URECPEv2i32
  URHADDv2i32
  URHADDv4i16
  URHADDv8i8
  URSHLv1i64
  URSHLv2i32
  URSHLv4i16
  URSHLv8i8
  URSHRd
  URSHRv2i32_shift
  URSHRv4i16_shift
  URSHRv8i8_shift
  URSQRTEv2i32
  URSRAd
  URSRAv2i32_shift
  URSRAv4i16_shift
  URSRAv8i8_shift
  USDOTlanev8i8
  USDOTv8i8
  USHLv1i64
  USHLv2i32
  USHLv4i16
  USHLv8i8
  USHRd
  USHRv2i32_shift
  USHRv4i16_shift
  USHRv8i8_shift
  USQADDv1i64
  USQADDv2i32
  USQADDv4i16
  USQADDv8i8
  USRAd
  USRAv2i32_shift
  USRAv4i16_shift
  USRAv8i8_shift
  UZP1v2i32
  UZP1v4i16
  UZP1v8i8
  UZP2v2i32
  UZP2v4i16
  UZP2v8i8
  XTNv2i32
  XTNv4i16
  XTNv8i8
  ZIP1v2i32
  ZIP1v4i16
  ZIP1v8i8
  ZIP2v2i32
  ZIP2v4i16
  ZIP2v8i8
2023-05-05 17:26:53 +01:00
Jingu Kang
932911d6b1 [AArch64] Remove redundant mov 0 instruction for high 64-bits
If MI sets zero for high 64-bits implicitly, remove `mov 0` for high 64-bits.
For example,

 %1:fpr64 = nofpexcept FCVTNv4i16 %0:fpr128, implicit $fpcr
 %2:fpr64 = MOVID 0
 %4:fpr128 = IMPLICIT_DEF
 %3:fpr128 = INSERT_SUBREG %4:fpr128(tied-def 0), killed %2:fpr64, %subreg.dsub
 %6:fpr128 = IMPLICIT_DEF
 %5:fpr128 = INSERT_SUBREG %6:fpr128(tied-def 0), killed %1:fpr64, %subreg.dsub
 %7:fpr128 = INSvi64lane %5:fpr128(tied-def 0), 1, killed %3:fpr128, 0
 ==>
 %1:fpr64 = nofpexcept FCVTNv4i16 %0:fpr128, implicit $fpcr
 %6:fpr128 = IMPLICIT_DEF
 %7:fpr128 = INSERT_SUBREG %6:fpr128(tied-def 0), killed %1:fpr64, %subreg.dsub

Differential Revision: https://reviews.llvm.org/D147235
2023-04-03 10:39:54 +01:00
Kazu Hirata
fa66e4bd93 [AArch64] Fix a warning
This patch fixes:

  llvm/lib/Target/AArch64/AArch64MIPeepholeOpt.cpp:582:17: error:
  unused variable 'INSvilaneMI' [-Werror,-Wunused-variable]
2023-02-27 13:01:02 -08:00
Nilanjana Basu
72105d10d5 [AArch64] Avoid using intermediate integer registers for copying between source and destination floating point registers
In post-isel code, there are cases where there were redundant copies from a source FPR to an intermediate GPR in order to copy to a destination FPR. In this patch, we identify these patterns in post-isel peephole optimization and replace them with a direct FPR-to-FPR copy.
One example for this will be the insertion of the scalar result of 'uaddlv' neon intrinsic function into a destination vector. During instruction selection phase, 'uaddlv' result is copied to a GPR, & a vector insert instruction is matched separately to copy the previous result to a destination SIMD&FP register.

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D142594
2023-02-27 12:20:10 -08:00
David Green
b134c62fac [AArch64] Fix creation of invalid instructions with XZR register
A combination of GlobalISel and MachineCombiner can end up creating
`SUB xrz, (MOVI -2105098)` instructions which have not been constant
folded. The AArch64MIPeepholeOpt pass will then attempt to create
`ADD xzr, 513, lsl 12`, which is not a valid instruction. This adds
a bail out of the transform if the register is xzr/wzr.

Fixes #60528

Differential Revision: https://reviews.llvm.org/D143475
2023-02-08 13:17:10 +00:00
Kazu Hirata
e078201835 [Target] Use llvm::count{l,r}_{zero,one} (NFC) 2023-01-28 09:23:07 -08:00
Fangrui Song
4b1b9e22b3 Remove unused #include "llvm/ADT/Optional.h" 2022-12-05 04:21:08 +00:00
Fangrui Song
b0df70403d [Target] llvm::Optional => std::optional
The updated functions are mostly internal with a few exceptions (virtual functions in
TargetInstrInfo.h, TargetRegisterInfo.h).
To minimize changes to LLVMCodeGen, GlobalISel files are skipped.

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-04 22:43:14 +00:00
Kazu Hirata
20cde15415 [Target] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-02 20:36:06 -08:00
Kazu Hirata
20d764aff0 [llvm] Don't including SetVector.h (NFC)
llvm/lib/ProfileData/RawMemProfReader.cpp uses SetVector without
including SetVector.h, so this patch adds an appropriate #include
there.
2022-09-17 12:36:43 -07:00
Fangrui Song
f9b5924975 [AArch64] Fix -Wunused-variable. NFC 2022-09-08 18:27:16 -07:00
zhongyunde
b6655333c2 [Peephole] rewrite INSERT_SUBREG to SUBREG_TO_REG if upper bits zero
Restrict the 32-bit form of an instruction of integer as too many test cases
will be clobber as the register number updated.
    From %reg = INSERT_SUBREG %reg, %subreg, subidx
    To   %reg:subidx =  SUBREG_TO_REG 0, %subreg, subidx
Try to prefix the redundant mov instruction at D132325 as the SUBREG_TO_REG should not generate code.

Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D132939
2022-09-09 09:00:54 +08:00
Kazu Hirata
7a47ee51a1 [llvm] Don't use Optional::getValue (NFC) 2022-06-20 22:45:45 -07:00
David Green
a1aef4f374 [AArch64] Remove ToBeRemoved from AArch64MIPeepholeOpt
The ToBeRemoved is used to remove any MachineInstructions that are no
longer needed, making sure we don't invalidate the iterator that is
currently in use by erasing the instruction straight away. This makes
issues for keeping the code in SSA from though, where subsequent
transforms that require SSA form may have been broken by previous
peepholes.

If, instead, we use make_early_inc_range the iteration issue shouldn't
be present, so long as we do not remove the subsequent instruction in
the peephole optimizations. That way the code between transforms is kept
in SSA form, meaning hopefully less things that can go wrong.

Differential Revision: https://reviews.llvm.org/D127296
2022-06-08 17:26:07 +01:00
David Green
bccbf5276e [AArch64] Remove isDef32
isDef32 would attempt to make a guess at which SelectionDag nodes were
32bit sources, and use the nature of 32bit AArch64 instructions
implicitly zeroing the upper register half to not emit zext that were
expected to already be zero. This was a bit fragile though, needing to
guess at the correct opcodes that do not become 32bit defs later in
ISel.

This patch removed isDef32, relying on the AArch64MIPeephole optimizer
to remove redundant SUBREG_TO_REG nodes. A part of
SelectArithExtendedRegister was left with the same logic as a heuristic
to prevent some regressions from it picking less optimal sequences.
The AArch64MIPeepholeOpt pass also needs to be taught that a COPY from a
FPR will become a FMOVSWr, which it lowers immediately to make sure that
remains true through register allocation.

Fixes #55833

Differential Revision: https://reviews.llvm.org/D127154
2022-06-07 18:57:59 +01:00
Micah Weston
c69af70f02 [AArch64] Adds SUBS and ADDS instructions to the MIPeepholeOpt.
Implements ADDS/SUBS 24-bit immediate optimization using the
MIPeepholeOpt pass. This follows the pattern:

Optimize ([adds|subs] r, imm) -> ([ADDS|SUBS] ([ADD|SUB] r, #imm0, lsl #12), #imm1),
if imm == (imm0<<12)+imm1. and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

Optimize ([adds|subs] r, imm) -> ([SUBS|ADDS] ([SUB|ADD] r, #imm0, lsl #12), #imm1),
if imm == -(imm0<<12)-imm1, and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

The SplitAndOpcFunc type had to change the return type to an Opcode pair so that
the first add/sub is the regular instruction and the second is the flag setting
instruction. This required updating the code in the AND case.

Testing:

I ran a two stage bootstrap with this code.
Using the second stage compiler, I verified that the negation of an ADDS to SUBS
or vice versa is a valid optimization. Example V == -0x111111.

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D118663
2022-02-19 15:35:53 +00:00
Nathan Chancellor
22eb1dae3f
Revert "[AArch64] Adds SUBS and ADDS instructions to the MIPeepholeOpt."
This reverts commit af45d0fd94b21620b61c8c4900b81486fd85aeb7.

This causes assertions failures when compiling the Linux kernel. See
https://reviews.llvm.org/D118663 for a reduced reproducer.
2022-02-13 10:40:23 -07:00
Micah Weston
af45d0fd94 [AArch64] Adds SUBS and ADDS instructions to the MIPeepholeOpt.
Implements ADDS/SUBS 24-bit immediate optimization using the
MIPeepholeOpt pass. This follows the pattern:

Optimize ([adds|subs] r, imm) -> ([ADDS|SUBS] ([ADD|SUB] r, #imm0, lsl #12), #imm1),
if imm == (imm0<<12)+imm1. and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

Optimize ([adds|subs] r, imm) -> ([SUBS|ADDS] ([SUB|ADD] r, #imm0, lsl #12), #imm1),
if imm == -(imm0<<12)-imm1, and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

The SplitAndOpcFunc type had to change the return type to an Opcode pair so that
the first add/sub is the regular instruction and the second is the flag setting
instruction. This required updating the code in the AND case.

Testing:

I ran a two stage bootstrap with this code.
Using the second stage compiler, I verified that the negation of an ADDS to SUBS
or vice versa is a valid optimization. Example V == -0x111111.

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D118663
2022-02-12 03:13:14 +00:00
Micah Weston
f65651cc8a [AArch64] Fixes ADD/SUB opt bug and abstracts shared behavior in MIPeepholeOpt for ADD, SUB, and AND.
This fixes a bug where (SUBREG_TO_REG 0 (MOVi32imm <negative-number>) sub_32)
would generate invalid code since the top 32-bits were not zeroed when inspecting the
immediate value. A new test was added for this case.

Change to abstract shared behavior in MIPeepholeOpt. Both
visitAND and visitADDSUB attempt to split an RR instruction with an immediate
operand into two RI instructions with the immediate split.

The differing behavior lies in how the immediate is split into two pieces and
how the new instructions are built. The rest of the behavior (adding new VRegs,
checking for the MOVImm, constraining reg classes, removing old intructions)
are shared between the operations.

The new helper function splitTwoPartImm implements the shared behavior and
delegates differing behavior to two function objects passed by the caller.
One function object splits the immediate into two values and returns the
opcode to use if it is a valid split. The other function object builds
the new instructions.

I felt this abstraction would help since I believe it will help reduce the
code repetition when adding new instructions of the pattern, such as
SUBS for this conditional optimization.

Tested it locally by running check all with compiler-rt, mlir, clang-tools-extra,
flang, llvm, and clang enabled.

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D118000
2022-01-26 04:22:27 +00:00
Micah Weston
93deac2e2b [AArch64] Optimize add/sub with immediate through MIPeepholeOpt
Fixes the build issue with D111034, whose goal was to optimize
add/sub with long immediates.

Optimize ([add|sub] r, imm) -> ([ADD|SUB] ([ADD|SUB] r, #imm0, lsl #12), #imm1),
if imm == (imm0<<12)+imm1. and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

Optimize ([add|sub] r, imm) -> ([SUB|ADD] ([SUB|ADD] r, #imm0, lsl #12), #imm1),
if imm == -(imm0<<12)-imm1, and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

The change which fixed the build issue in D111034 was the use of new virtual
registers so that SSA form is maintained until deleting MI.

Differential Revision: https://reviews.llvm.org/D117429
2022-01-22 12:39:22 +00:00
Florian Hahn
62476c7c14
Revert "[AArch64] Revive optimize add/sub with immediate through MIPeepholeOpt"
This reverts commit e6698f09929a134bf0f46d9347142b86d8f636a2.

This commit appears to introduce new machine verifier failures when
building the llvm-test-suite with `-mllvm -verify-machineinstrs` enabled:

https://green.lab.llvm.org/green/job/test-suite-verify-machineinstrs-aarch64-O3/11061/

FAILED: MultiSource/Benchmarks/Olden/health/CMakeFiles/health.dir/health.c.o
/Users/buildslave/jenkins/workspace/test-suite-verify-machineinstrs-aarch64-O3/test-suite-build/tools/timeit --summary MultiSource/Benchmarks/Olden/health/CMakeFiles/health.dir/health.c.o.time /Users/buildslave/jenkins/workspace/test-suite-verify-machineinstrs-aarch64-O3/compiler/bin/clang -DNDEBUG  -B /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin    -Wno-unused-command-line-argument -mllvm -verify-machineinstrs -O3 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk   -w -Werror=date-time -DTORONTO -MD -MT MultiSource/Benchmarks/Olden/health/CMakeFiles/health.dir/health.c.o -MF MultiSource/Benchmarks/Olden/health/CMakeFiles/health.dir/health.c.o.d -o MultiSource/Benchmarks/Olden/health/CMakeFiles/health.dir/health.c.o   -c /Users/buildslave/jenkins/workspace/test-suite-verify-machineinstrs-aarch64-O3/test-suite/MultiSource/Benchmarks/Olden/health/health.c
*** Bad machine code: Illegal virtual register for instruction ***
- function:    alloc_tree
- basic block: %bb.1 if.else (0x7fc0db8f8bb0)
- instruction: %31:gpr64 = nsw MADDXrrr killed %39:gpr64sp, killed %25:gpr64, $xzr
- operand 1:   killed %39:gpr64sp
Expected a GPR64 register, but got a GPR64sp register
fatal error: error in backend: Found 1 machine code errors.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /Users/buildslave/jenkins/workspace/test-suite-verify-machineinstrs-aarch64-O3/compiler/bin/clang -DNDEBUG -B /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin -Wno-unused-command-line-argument -mllvm -verify-machineinstrs -O3 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk -w -Werror=date-time -DTORONTO -MD -MT MultiSource/Benchmarks/Olden/health/CMakeFiles/health.dir/health.c.o -MF MultiSource/Benchmarks/Olden/health/CMakeFiles/health.dir/health.c.o.d -o MultiSource/Benchmarks/Olden/health/CMakeFiles/health.dir/health.c.o -c /Users/buildslave/jenkins/workspace/test-suite-verify-machineinstrs-aarch64-O3/test-suite/MultiSource/Benchmarks/Olden/health/health.c
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '/Users/buildslave/jenkins/workspace/test-suite-verify-machineinstrs-aarch64-O3/test-suite/MultiSource/Benchmarks/Olden/health/health.c'.
4.	Running pass 'Verify generated machine code' on function '@alloc_tree'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  clang         0x000000011191896b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 43
1  clang         0x00000001119179b5 llvm::sys::RunSignalHandlers() + 85
2  clang         0x00000001119180e2 llvm::sys::CleanupOnSignal(unsigned long) + 210
3  clang         0x0000000111849f6a (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) + 106
4  clang         0x0000000111849ee8 llvm::CrashRecoveryContext::HandleExit(int) + 24
5  clang         0x0000000111914acc llvm::sys::Process::Exit(int, bool) + 44
6  clang         0x000000010f4e9be9 LLVMErrorHandler(void*, char const*, bool) + 89
7  clang         0x0000000114eba333 llvm::report_fatal_error(llvm::Twine const&, bool) + 323
8  clang         0x0000000110d8c620 (anonymous namespace)::MachineVerifier::BBInfo::~BBInfo() + 0
9  clang         0x0000000110cdddca llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 378
10 clang         0x00000001110b0154 llvm::FPPassManager::runOnFunction(llvm::Function&) + 1092
11 clang         0x00000001110b6268 llvm::FPPassManager::runOnModule(llvm::Module&) + 72
12 clang         0x00000001110b074a llvm::legacy::PassManagerImpl::run(llvm::Module&) + 986
13 clang         0x0000000111c20ad4 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream> >) + 3764
14 clang         0x0000000111f6dd31 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 1905
15 clang         0x00000001131a28b3 clang::ParseAST(clang::Sema&, bool, bool) + 643
16 clang         0x00000001122b02a4 clang::FrontendAction::Execute() + 84
17 clang         0x000000011222d6a9 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 873
18 clang         0x000000011232faf5 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 661
19 clang         0x000000010f4e9860 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 2544
20 clang         0x000000010f4e7168 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) + 312
21 clang         0x00000001120ab187 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, bool*) const::$_1>(long) + 23
22 clang         0x0000000111849eb4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 228
23 clang         0x00000001120aac24 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, bool*) const + 324
24 clang         0x000000011207b85d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const + 221
25 clang         0x000000011207bdad clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) const + 125
26 clang         0x0000000112092f7c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) + 204
27 clang         0x000000010f4e6977 main + 10375
28 libdyld.dylib 0x00007fff6be90cc9 start + 1
29 libdyld.dylib 0x0000000000000018 start + 18446603338705728336
clang-14: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 14.0.0 (https://github.com/llvm/llvm-project.git c90d136be4e055f1b409f38706d0fe3e2211af08)
Target: arm64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Users/buildslave/jenkins/workspace/test-suite-verify-machineinstrs-aarch64-O3/compiler/bin
clang-14: note: diagnostic msg:
********************
2022-01-18 13:17:02 +00:00
Micah Weston
e6698f0992 [AArch64] Revive optimize add/sub with immediate through MIPeepholeOpt
Fixes the build issue with D111034, whose goal was to optimize
add/sub with long immediates.

Optimize ([add|sub] r, imm) -> ([ADD|SUB] ([ADD|SUB] r, #imm0, lsl #12), #imm1),
if imm == (imm0<<12)+imm1. and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

Optimize ([add|sub] r, imm) -> ([SUB|ADD] ([SUB|ADD] r, #imm0, lsl #12), #imm1),
if imm == -(imm0<<12)-imm1, and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

The change which fixed the build issue in D111034 was the use of new virtual
registers so that SSA form is maintained until deleting MI.

Differential Revision: https://reviews.llvm.org/D117429
2022-01-17 17:17:15 +00:00
David Green
43e500d791 [AArch64] Minor AArch64MIPeepholeOpt cleanup. NFC
We should always be in SSA form when running the pass, so turn a check
into an assert.
2021-12-28 19:10:01 +00:00
Ben Shi
59c3b48d99 Revert "[AArch64] Optimize add/sub with immediate"
This reverts commit 3de3ca3137bec5115cd10c53f4059f9bf1054e96.
2021-11-03 14:15:21 +08:00
Ben Shi
3de3ca3137 [AArch64] Optimize add/sub with immediate
Optimize ([add|sub] r, imm) -> ([ADD|SUB] ([ADD|SUB] r, #imm0, lsl #12), #imm1),
if imm == (imm0<<12)+imm1. and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

Optimize ([add|sub] r, imm) -> ([SUB|ADD] ([SUB|ADD] r, #imm0, lsl #12), #imm1),
if imm == -(imm0<<12)-imm1, and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

Reviewed By: jaykang10, dmgreen

Differential Revision: https://reviews.llvm.org/D111034
2021-11-03 03:06:43 +00:00
Jingu Kang
a502436259 [AArch64] Remove redundant ORRWrs which is generated by zero-extend
%3:gpr32 = ORRWrs $wzr, %2, 0
%4:gpr64 = SUBREG_TO_REG 0, %3, %subreg.sub_32

If AArch64's 32-bit form of instruction defines the source operand of ORRWrs,
we can remove the ORRWrs because the upper 32 bits of the source operand are
set to zero.

Differential Revision: https://reviews.llvm.org/D110841
2021-10-25 09:47:07 +01:00
Jingu Kang
3f0b178de2 [AArch64] Fixed a bug on AArch64MIPeepholeOpt
Create new virtual register for the definition of new AND instruction and
replace old register by the new one to keep SSA form.

Differential Revision: https://reviews.llvm.org/D109963
2021-10-18 08:55:42 +01:00
Ben Shi
d0dbc991c0 Revert "[AArch64] Optimize add/sub with immediate"
This reverts commit 9bf6bef9951a1c230796ccad2c5c0195ce4c4dff.
2021-10-16 22:17:18 +00:00
Ben Shi
9bf6bef995 [AArch64] Optimize add/sub with immediate
Optimize ([add|sub] r, imm) -> ([ADD|SUB] ([ADD|SUB] r, #imm0, lsl #12), #imm1),
if imm == (imm0<<12)+imm1. and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

Optimize ([add|sub] r, imm) -> ([SUB|ADD] ([SUB|ADD] r, #imm0, lsl #12), #imm1),
if imm == -(imm0<<12)-imm1, and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

Reviewed By: jaykang10, dmgreen

Differential Revision: https://reviews.llvm.org/D111034
2021-10-16 08:50:39 +00:00
Jingu Kang
30caca39f4 Third Recommit "[AArch64] Split bitmask immediate of bitwise AND operation"
This reverts the revert commit fc36fb4d23a5e419cf33002c87c0082f682cb77b with
bug fixes.

Differential Revision: https://reviews.llvm.org/D109963
2021-10-08 11:28:49 +01:00
David Spickett
fc36fb4d23 Revert "Second Recommit "[AArch64] Split bitmask immediate of bitwise AND operation""
This reverts commit 13f3c39f3658fa28cb008eb56a58d8e34697cd5d.

Due to test failures in stage 2 clang tests on AArch64 bots.
2021-10-06 08:39:48 +00:00
Jingu Kang
13f3c39f36 Second Recommit "[AArch64] Split bitmask immediate of bitwise AND operation"
This reverts the revert commit c07f7099690e8607d119227db1f80ee21eff3a3b with
bug fixes.

Differential Revision: https://reviews.llvm.org/D109963
2021-09-30 09:27:08 +01:00
Sterling Augustine
c07f709969 Revert "Recommit "[AArch64] Split bitmask immediate of bitwise AND operation""
This reverts commit 73a196a11c0e6fe7bbf33055cc2c96ce3c61ff0d.

Causes crashes as reported in https://reviews.llvm.org/D109963
2021-09-28 18:02:06 -07:00
Jingu Kang
73a196a11c Recommit "[AArch64] Split bitmask immediate of bitwise AND operation"
This reverts the revert commit f85d8a5bed95cc17a452b6b63b9866fbf181d94d
with bug fixes.

Original message:

    MOVi32imm + ANDWrr ==> ANDWri + ANDWri
    MOVi64imm + ANDXrr ==> ANDXri + ANDXri

    The mov pseudo instruction could be expanded to multiple mov instructions later.
    In this case, try to split the constant operand of mov instruction into two
    bitmask immediates. It makes only two AND instructions intead of multiple
    mov + and instructions.

    Added a peephole optimization pass on MIR level to implement it.

    Differential Revision: https://reviews.llvm.org/D109963
2021-09-28 15:26:29 +01:00
Jingu Kang
f85d8a5bed Revert "[AArch64] Split bitmask immediate of bitwise AND operation"
This reverts commit 864b206796ae8aa7f35f830655337751dbd9176c.

Reverting due to error on buildbots.
2021-09-28 13:28:09 +01:00
Jingu Kang
864b206796 [AArch64] Split bitmask immediate of bitwise AND operation
MOVi32imm + ANDWrr ==> ANDWri + ANDWri
MOVi64imm + ANDXrr ==> ANDXri + ANDXri

The mov pseudo instruction could be expanded to multiple mov instructions later.
In this case, try to split the constant operand of mov instruction into two
bitmask immediates. It makes only two AND instructions intead of multiple
mov + and instructions.

Added a peephole optimization pass on MIR level to implement it.

Differential Revision: https://reviews.llvm.org/D109963
2021-09-28 11:57:43 +01:00