diff options
author | Kai Nacke <kai@redstar.de> | 2022-08-05 06:55:40 -0400 |
---|---|---|
committer | Kai Nacke <kai@redstar.de> | 2022-11-13 11:07:41 -0500 |
commit | cfb97cbeca964d2f7d5761f7c3438297235b7d96 (patch) | |
tree | 0cd4bc5e0e2c80153c4fd1436e6e2a66072f02b8 | |
parent | d65c906938116772e2a1c46dcb7f699694ec8d3d (diff) | |
download | llvm-cfb97cbeca964d2f7d5761f7c3438297235b7d96.zip llvm-cfb97cbeca964d2f7d5761f7c3438297235b7d96.tar.gz llvm-cfb97cbeca964d2f7d5761f7c3438297235b7d96.tar.bz2 |
[m88k] Use REG_SEQUENCE when lowering G_MERGE_VALUES
Also updates float and int arithmetic tests. The allocated registers
looks sane now, mostly due to not using -O1.
A new test discovers a bug when negating doubles.
-rw-r--r-- | llvm/lib/Target/M88k/GISel/M88kInstructionSelector.cpp | 34 | ||||
-rw-r--r-- | llvm/test/CodeGen/M88k/floatarith.ll | 127 | ||||
-rw-r--r-- | llvm/test/CodeGen/M88k/intarith.ll | 8 |
3 files changed, 82 insertions, 87 deletions
diff --git a/llvm/lib/Target/M88k/GISel/M88kInstructionSelector.cpp b/llvm/lib/Target/M88k/GISel/M88kInstructionSelector.cpp index 8024500..d7d18b7 100644 --- a/llvm/lib/Target/M88k/GISel/M88kInstructionSelector.cpp +++ b/llvm/lib/Target/M88k/GISel/M88kInstructionSelector.cpp @@ -866,30 +866,16 @@ bool M88kInstructionSelector::selectMergeUnmerge( MachineInstr *MI = nullptr; if (I.getOpcode() == TargetOpcode::G_MERGE_VALUES) { - Register ImpDefReg = MRI.createVirtualRegister(&M88k::GPR64RCRegClass); - MI = BuildMI(MBB, I, I.getDebugLoc(), TII.get(TargetOpcode::IMPLICIT_DEF), - ImpDefReg); - constrainSelectedInstRegOperands(*MI, TII, TRI, RBI); - - Register HiReg = MRI.createVirtualRegister(&M88k::GPR64RCRegClass); - MI = BuildMI(MBB, I, I.getDebugLoc(), TII.get(TargetOpcode::INSERT_SUBREG), - HiReg) - .addUse(ImpDefReg) - .addUse(I.getOperand(1).getReg()) - .addImm(M88k::sub_hi); - constrainSelectedInstRegOperands(*MI, TII, TRI, RBI); - - Register HiLoReg = MRI.createVirtualRegister(&M88k::GPR64RCRegClass); - MI = BuildMI(MBB, I, I.getDebugLoc(), TII.get(TargetOpcode::INSERT_SUBREG), - HiLoReg) - .addUse(HiReg) - .addUse(I.getOperand(2).getReg()) - .addImm(M88k::sub_lo); - constrainSelectedInstRegOperands(*MI, TII, TRI, RBI); - - MI = BuildMI(MBB, I, I.getDebugLoc(), TII.get(TargetOpcode::COPY), - I.getOperand(0).getReg()) - .addUse(HiLoReg); + Register DstReg = I.getOperand(0).getReg(); + Register LoReg = I.getOperand(1).getReg(); + Register HiReg = I.getOperand(2).getReg(); + MI = BuildMI(MBB, I, I.getDebugLoc(), TII.get(TargetOpcode::REG_SEQUENCE), + DstReg) + .addUse(LoReg) + .addImm(M88k::sub_lo) + .addUse(HiReg) + .addImm(M88k::sub_hi); + RBI.constrainGenericRegister(DstReg, M88k::GPR64RCRegClass, MRI); } else { Register SrcReg = I.getOperand(2).getReg(); diff --git a/llvm/test/CodeGen/M88k/floatarith.ll b/llvm/test/CodeGen/M88k/floatarith.ll index a61f4fa..52fc07e 100644 --- a/llvm/test/CodeGen/M88k/floatarith.ll +++ b/llvm/test/CodeGen/M88k/floatarith.ll @@ -1,38 +1,47 @@ ; Test floating point arithmetic. ; -; RUN: llc < %s -mtriple=m88k-openbsd -mcpu=mc88100 -O0 | FileCheck --check-prefixes=CHECK,MC88100 %s -; RUN: llc < %s -mtriple=m88k-openbsd -mcpu=mc88110 -O0 | FileCheck --check-prefixes=CHECK,MC88110 %s +; RUN: llc < %s -mtriple=m88k-openbsd -mcpu=mc88100 -m88k-enable-delay-slot-filler=false | FileCheck --check-prefixes=CHECK,MC88100 %s +; RUN: llc < %s -mtriple=m88k-openbsd -mcpu=mc88110 -m88k-enable-delay-slot-filler=false | FileCheck --check-prefixes=CHECK,MC88110 %s define float @trunc(double %a) { ; CHECK-LABEL: trunc: ; MC88100: fsub.sds %r2, %r2, %r0 ; MC88110: fcvt.sd %r2, %r2 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %trnc = fptrunc double %a to float ret float %trnc } define double @extend(float %a) { ; CHECK-LABEL: extend: -; MC88100: fsub.dss %r4, %r2, %r0 -; MC88110: fcvt.ds %r4, %r2 -; CHECK: jmp %r1 +; MC88100: fsub.dss %r2, %r2, %r0 +; MC88110: fcvt.ds %r2, %r2 +; CHECK-NEXT: jmp %r1 %ext = fpext float %a to double ret double %ext } -define float @negate(float %a) { -; CHECK-LABEL: negate: +define float @negate1(float %a) { +; CHECK-LABEL: negate1: ; CHECK: xor.u %r2, %r2, 32768 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %neg = fneg float %a ret float %neg } +define double @negate2(double %a) { +; CHECK-LABEL: negate2: +; BUG!!! r3 is zero'ed - why? +; CHECK: xor.u %r2, %r2, 32768 +; CHECK-NEXT: jmp %r1 + %neg = fneg double %a + ret double %neg +} + define i32 @f32tosi32(float %a) { ; CHECK-LABEL: f32tosi32: ; CHECK: trnc.ss %r2, %r2 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %trnc = fptosi float %a to i32 ret i32 %trnc } @@ -40,7 +49,7 @@ define i32 @f32tosi32(float %a) { define i32 @f64tosi32(double %a) { ; CHECK-LABEL: f64tosi32: ; CHECK: trnc.sd %r2, %r2 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %trnc = fptosi double %a to i32 ret i32 %trnc } @@ -64,7 +73,7 @@ define i64 @f64tosi64(double %a) { define float @fadd1(float %a, float %b) { ; CHECK-LABEL: fadd1: ; CHECK: fadd.sss %r2, %r2, %r3 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %sum = fadd float %a, %b ret float %sum } @@ -72,7 +81,7 @@ define float @fadd1(float %a, float %b) { define float @fadd2(float %a, double %b) { ; CHECK-LABEL: fadd2: ; CHECK: fadd.ssd %r2, %r2, %r4 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %ext = fpext float %a to double %sum = fadd double %ext, %b %trnc = fptrunc double %sum to float @@ -82,7 +91,7 @@ define float @fadd2(float %a, double %b) { define float @fadd3(double %a, float %b) { ; CHECK-LABEL: fadd3: ; CHECK: fadd.sds %r2, %r2, %r4 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %ext = fpext float %b to double %sum = fadd double %a, %ext %trnc = fptrunc double %sum to float @@ -92,7 +101,7 @@ define float @fadd3(double %a, float %b) { define float @fadd4(double %a, double %b) { ; CHECK-LABEL: fadd4: ; CHECK: fadd.sdd %r2, %r2, %r4 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %sum = fadd double %a, %b %trnc = fptrunc double %sum to float ret float %trnc @@ -100,16 +109,16 @@ define float @fadd4(double %a, double %b) { define double @fadd5(double %a, double %b) { ; CHECK-LABEL: fadd5: -; CHECK: fadd.ddd %r4, %r2, %r4 -; CHECK: jmp %r1 +; CHECK: fadd.ddd %r2, %r2, %r4 +; CHECK-NEXT: jmp %r1 %sum = fadd double %a, %b ret double %sum } define double @fadd6(double %a, float %b) { ; CHECK-LABEL: fadd6: -; CHECK: fadd.dds %r4, %r2, %r4 -; CHECK: jmp %r1 +; CHECK: fadd.dds %r2, %r2, %r4 +; CHECK-NEXT: jmp %r1 %ext = fpext float %b to double %sum = fadd double %a, %ext ret double %sum @@ -117,8 +126,8 @@ define double @fadd6(double %a, float %b) { define double @fadd7(float %a, double %b) { ; CHECK-LABEL: fadd7: -; CHECK: fadd.dsd %r4, %r2, %r4 -; CHECK: jmp %r1 +; CHECK: fadd.dsd %r2, %r2, %r4 +; CHECK-NEXT: jmp %r1 %ext = fpext float %a to double %sum = fadd double %ext, %b ret double %sum @@ -126,8 +135,8 @@ define double @fadd7(float %a, double %b) { define double @fadd8(float %a, float %b) { ; CHECK-LABEL: fadd8: -; CHECK: fadd.dss %r4, %r2, %r3 -; CHECK: jmp %r1 +; CHECK: fadd.dss %r2, %r2, %r3 +; CHECK-NEXT: jmp %r1 %sum = fadd float %a, %b %ext = fpext float %sum to double ret double %ext @@ -136,7 +145,7 @@ define double @fadd8(float %a, float %b) { define float @fsub1(float %a, float %b) { ; CHECK-LABEL: fsub1: ; CHECK: fsub.sss %r2, %r2, %r3 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %sum = fsub float %a, %b ret float %sum } @@ -144,7 +153,7 @@ define float @fsub1(float %a, float %b) { define float @fsub2(float %a, double %b) { ; CHECK-LABEL: fsub2: ; CHECK: fsub.ssd %r2, %r2, %r4 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %ext = fpext float %a to double %sum = fsub double %ext, %b %trnc = fptrunc double %sum to float @@ -154,7 +163,7 @@ define float @fsub2(float %a, double %b) { define float @fsub3(double %a, float %b) { ; CHECK-LABEL: fsub3: ; CHECK: fsub.sds %r2, %r2, %r4 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %ext = fpext float %b to double %sum = fsub double %a, %ext %trnc = fptrunc double %sum to float @@ -164,7 +173,7 @@ define float @fsub3(double %a, float %b) { define float @fsub4(double %a, double %b) { ; CHECK-LABEL: fsub4: ; CHECK: fsub.sdd %r2, %r2, %r4 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %sum = fsub double %a, %b %trnc = fptrunc double %sum to float ret float %trnc @@ -172,16 +181,16 @@ define float @fsub4(double %a, double %b) { define double @fsub5(double %a, double %b) { ; CHECK-LABEL: fsub5: -; CHECK: fsub.ddd %r4, %r2, %r4 -; CHECK: jmp %r1 +; CHECK: fsub.ddd %r2, %r2, %r4 +; CHECK-NEXT: jmp %r1 %sum = fsub double %a, %b ret double %sum } define double @fsub6(double %a, float %b) { ; CHECK-LABEL: fsub6: -; CHECK: fsub.dds %r4, %r2, %r4 -; CHECK: jmp %r1 +; CHECK: fsub.dds %r2, %r2, %r4 +; CHECK-NEXT: jmp %r1 %ext = fpext float %b to double %sum = fsub double %a, %ext ret double %sum @@ -189,8 +198,8 @@ define double @fsub6(double %a, float %b) { define double @fsub7(float %a, double %b) { ; CHECK-LABEL: fsub7: -; CHECK: fsub.dsd %r4, %r2, %r4 -; CHECK: jmp %r1 +; CHECK: fsub.dsd %r2, %r2, %r4 +; CHECK-NEXT: jmp %r1 %ext = fpext float %a to double %sum = fsub double %ext, %b ret double %sum @@ -198,8 +207,8 @@ define double @fsub7(float %a, double %b) { define double @fsub8(float %a, float %b) { ; CHECK-LABEL: fsub8: -; CHECK: fsub.dss %r4, %r2, %r3 -; CHECK: jmp %r1 +; CHECK: fsub.dss %r2, %r2, %r3 +; CHECK-NEXT: jmp %r1 %sum = fsub float %a, %b %ext = fpext float %sum to double ret double %ext @@ -208,7 +217,7 @@ define double @fsub8(float %a, float %b) { define float @fmul1(float %a, float %b) { ; CHECK-LABEL: fmul1: ; CHECK: fmul.sss %r2, %r2, %r3 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %sum = fmul float %a, %b ret float %sum } @@ -216,7 +225,7 @@ define float @fmul1(float %a, float %b) { define float @fmul2(float %a, double %b) { ; CHECK-LABEL: fmul2: ; CHECK: fmul.ssd %r2, %r2, %r4 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %ext = fpext float %a to double %sum = fmul double %ext, %b %trnc = fptrunc double %sum to float @@ -226,7 +235,7 @@ define float @fmul2(float %a, double %b) { define float @fmul3(double %a, float %b) { ; CHECK-LABEL: fmul3: ; CHECK: fmul.sds %r2, %r2, %r4 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %ext = fpext float %b to double %sum = fmul double %a, %ext %trnc = fptrunc double %sum to float @@ -236,7 +245,7 @@ define float @fmul3(double %a, float %b) { define float @fmul4(double %a, double %b) { ; CHECK-LABEL: fmul4: ; CHECK: fmul.sdd %r2, %r2, %r4 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %sum = fmul double %a, %b %trnc = fptrunc double %sum to float ret float %trnc @@ -244,16 +253,16 @@ define float @fmul4(double %a, double %b) { define double @fmul5(double %a, double %b) { ; CHECK-LABEL: fmul5: -; CHECK: fmul.ddd %r4, %r2, %r4 -; CHECK: jmp %r1 +; CHECK: fmul.ddd %r2, %r2, %r4 +; CHECK-NEXT: jmp %r1 %sum = fmul double %a, %b ret double %sum } define double @fmul6(double %a, float %b) { ; CHECK-LABEL: fmul6: -; CHECK: fmul.dds %r4, %r2, %r4 -; CHECK: jmp %r1 +; CHECK: fmul.dds %r2, %r2, %r4 +; CHECK-NEXT: jmp %r1 %ext = fpext float %b to double %sum = fmul double %a, %ext ret double %sum @@ -261,8 +270,8 @@ define double @fmul6(double %a, float %b) { define double @fmul7(float %a, double %b) { ; CHECK-LABEL: fmul7: -; CHECK: fmul.dsd %r4, %r2, %r4 -; CHECK: jmp %r1 +; CHECK: fmul.dsd %r2, %r2, %r4 +; CHECK-NEXT: jmp %r1 %ext = fpext float %a to double %sum = fmul double %ext, %b ret double %sum @@ -270,8 +279,8 @@ define double @fmul7(float %a, double %b) { define double @fmul8(float %a, float %b) { ; CHECK-LABEL: fmul8: -; CHECK: fmul.dss %r4, %r2, %r3 -; CHECK: jmp %r1 +; CHECK: fmul.dss %r2, %r2, %r3 +; CHECK-NEXT: jmp %r1 %sum = fmul float %a, %b %ext = fpext float %sum to double ret double %ext @@ -280,7 +289,7 @@ define double @fmul8(float %a, float %b) { define float @fdiv1(float %a, float %b) { ; CHECK-LABEL: fdiv1: ; CHECK: fdiv.sss %r2, %r2, %r3 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %sum = fdiv float %a, %b ret float %sum } @@ -288,7 +297,7 @@ define float @fdiv1(float %a, float %b) { define float @fdiv2(float %a, double %b) { ; CHECK-LABEL: fdiv2: ; CHECK: fdiv.ssd %r2, %r2, %r4 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %ext = fpext float %a to double %sum = fdiv double %ext, %b %trnc = fptrunc double %sum to float @@ -298,7 +307,7 @@ define float @fdiv2(float %a, double %b) { define float @fdiv3(double %a, float %b) { ; CHECK-LABEL: fdiv3: ; CHECK: fdiv.sds %r2, %r2, %r4 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %ext = fpext float %b to double %sum = fdiv double %a, %ext %trnc = fptrunc double %sum to float @@ -308,7 +317,7 @@ define float @fdiv3(double %a, float %b) { define float @fdiv4(double %a, double %b) { ; CHECK-LABEL: fdiv4: ; CHECK: fdiv.sdd %r2, %r2, %r4 -; CHECK: jmp %r1 +; CHECK-NEXT: jmp %r1 %sum = fdiv double %a, %b %trnc = fptrunc double %sum to float ret float %trnc @@ -316,16 +325,16 @@ define float @fdiv4(double %a, double %b) { define double @fdiv5(double %a, double %b) { ; CHECK-LABEL: fdiv5: -; CHECK: fdiv.ddd %r4, %r2, %r4 -; CHECK: jmp %r1 +; CHECK: fdiv.ddd %r2, %r2, %r4 +; CHECK-NEXT: jmp %r1 %sum = fdiv double %a, %b ret double %sum } define double @fdiv6(double %a, float %b) { ; CHECK-LABEL: fdiv6: -; CHECK: fdiv.dds %r4, %r2, %r4 -; CHECK: jmp %r1 +; CHECK: fdiv.dds %r2, %r2, %r4 +; CHECK-NEXT: jmp %r1 %ext = fpext float %b to double %sum = fdiv double %a, %ext ret double %sum @@ -333,8 +342,8 @@ define double @fdiv6(double %a, float %b) { define double @fdiv7(float %a, double %b) { ; CHECK-LABEL: fdiv7: -; CHECK: fdiv.dsd %r4, %r2, %r4 -; CHECK: jmp %r1 +; CHECK: fdiv.dsd %r2, %r2, %r4 +; CHECK-NEXT: jmp %r1 %ext = fpext float %a to double %sum = fdiv double %ext, %b ret double %sum @@ -342,8 +351,8 @@ define double @fdiv7(float %a, double %b) { define double @fdiv8(float %a, float %b) { ; CHECK-LABEL: fdiv8: -; CHECK: fdiv.dss %r4, %r2, %r3 -; CHECK: jmp %r1 +; CHECK: fdiv.dss %r2, %r2, %r3 +; CHECK-NEXT: jmp %r1 %sum = fdiv float %a, %b %ext = fpext float %sum to double ret double %ext diff --git a/llvm/test/CodeGen/M88k/intarith.ll b/llvm/test/CodeGen/M88k/intarith.ll index 70e45b2..1763217 100644 --- a/llvm/test/CodeGen/M88k/intarith.ll +++ b/llvm/test/CodeGen/M88k/intarith.ll @@ -1,7 +1,7 @@ ; Test floating point arithmetic. ; -; RUN: llc < %s -mtriple=m88k-openbsd -mcpu=mc88100 -O0 | FileCheck --check-prefixes=CHECK,MC88100 %s -; RUN: llc < %s -mtriple=m88k-openbsd -mcpu=mc88110 -O0 | FileCheck --check-prefixes=CHECK,MC88110 %s +; RUN: llc < %s -mtriple=m88k-openbsd -mcpu=mc88100 -m88k-enable-delay-slot-filler=false | FileCheck --check-prefixes=CHECK,MC88100 %s +; RUN: llc < %s -mtriple=m88k-openbsd -mcpu=mc88110 -m88k-enable-delay-slot-filler=false | FileCheck --check-prefixes=CHECK,MC88110 %s define i64 @udiv64(i64 %a, i64 %b) { ; CHECK-LABEL: udiv64: @@ -14,7 +14,7 @@ define i64 @udiv64(i64 %a, i64 %b) { define i64 @udiv64with32(i64 %a, i32 %b) { ; CHECK-LABEL: udiv64with32: ; MC88100: bsr __udivdi3 -; MC88110: divu.d %r4, %r2, %r4 +; MC88110: divu.d %r2, %r2, %r4 ; CHECK: jmp %r1 %conv = zext i32 %b to i64 %quot = udiv i64 %a, %conv @@ -56,7 +56,7 @@ define i64 @mul64(i64 %a, i64 %b) { define i64 @mul32to64(i32 %a, i32 %b) { ; CHECK-LABEL: mul32to64: ; MC88100: bsr __muldi3 -; MC88110: mulu.d %r4, %r2, %r3 +; MC88110: mulu.d %r2, %r2, %r3 ; CHECK: jmp %r1 %conva = zext i32 %a to i64 %convb = zext i32 %b to i64 |