[AArch64][GlobalISel] Add the new changes to fix PR42129 that were supposed to go...
authorAmara Emerson <aemerson@apple.com>
Thu, 6 Jun 2019 07:33:47 +0000 (07:33 +0000)
committerAmara Emerson <aemerson@apple.com>
Thu, 6 Jun 2019 07:33:47 +0000 (07:33 +0000)
The changes weren't staged so ended up just re-commiting the unmodified reverted change.

llvm-svn: 362677

llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
llvm/test/CodeGen/AArch64/GlobalISel/fold-fp-select.mir

index c9af8fa..288ef2a 100644 (file)
@@ -2854,6 +2854,11 @@ bool AArch64InstructionSelector::tryOptSelect(MachineInstr &I) const {
     if (Opc != TargetOpcode::COPY && Opc != TargetOpcode::G_TRUNC)
       break;
 
+    // Can't see past copies from physregs.
+    if (Opc == TargetOpcode::COPY &&
+        TargetRegisterInfo::isPhysicalRegister(CondDef->getOperand(1).getReg()))
+      return false;
+
     CondDef = MRI.getVRegDef(CondDef->getOperand(1).getReg());
   }
 
index 619b927..81aa2cf 100644 (file)
@@ -349,3 +349,35 @@ body:             |
     RET_ReallyLR implicit $d0
 
 ...
+---
+name:            copy_from_physreg
+alignment:       2
+legalized:       true
+regBankSelected: true
+tracksRegLiveness: true
+body:             |
+  bb.0:
+    liveins: $s0, $w0, $w1
+
+    ; CHECK-LABEL: name: copy_from_physreg
+    ; CHECK: liveins: $s0, $w0, $w1
+    ; CHECK: [[COPY:%[0-9]+]]:gpr32 = COPY $w0
+    ; CHECK: [[COPY1:%[0-9]+]]:fpr32 = COPY $s0
+    ; CHECK: [[FMOVS0_:%[0-9]+]]:fpr32 = FMOVS0
+    ; CHECK: BL @copy_from_physreg, implicit-def $w0
+    ; CHECK: $wzr = ANDSWri [[COPY]], 0, implicit-def $nzcv
+    ; CHECK: [[FCSELSrrr:%[0-9]+]]:fpr32 = FCSELSrrr [[COPY1]], [[FMOVS0_]], 1, implicit $nzcv
+    ; CHECK: BL @copy_from_physreg, implicit-def $w0
+    ; CHECK: $s0 = COPY [[FCSELSrrr]]
+    ; CHECK: RET_ReallyLR implicit $s0
+    %0:gpr(s32) = COPY $w0
+    %1:fpr(s32) = COPY $s0
+    %5:fpr(s32) = G_FCONSTANT float 0.000000e+00
+    BL @copy_from_physreg, implicit-def $w0
+    %3:gpr(s1) = G_TRUNC %0(s32)
+    %4:fpr(s32) = G_SELECT %3(s1), %1, %5
+    BL @copy_from_physreg, implicit-def $w0
+    $s0 = COPY %4(s32)
+    RET_ReallyLR implicit $s0
+
+...