[PATCH] D80468: [ARM] select is not lowered in branching

kamlesh kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 23 18:02:39 PDT 2020


kamleshbhalui updated this revision to Diff 265901.
kamleshbhalui added a comment.

fixed failing testcase.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80468/new/

https://reviews.llvm.org/D80468

Files:
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMInstrVFP.td
  llvm/test/CodeGen/ARM/select.ll
  llvm/test/CodeGen/Thumb2/float-ops.ll


Index: llvm/test/CodeGen/Thumb2/float-ops.ll
===================================================================
--- llvm/test/CodeGen/Thumb2/float-ops.ll
+++ llvm/test/CodeGen/Thumb2/float-ops.ll
@@ -288,8 +288,7 @@
 ; SP-DAG: movne [[BHI]], [[AHI]]
 ; SP: vmov d0, [[BLO]], [[BHI]]
 ; DP: lsls   r0, r0, #31
-; VFP4-DP: vmovne.f64      d1, d0
-; VFP4-DP: vmov.f64        d0, d1
+; VFP4-DP: vmoveq.f64      d0, d1
 ; FP-ARMV8: vseleq.f64      d0, d1, d0
   %1 = select i1 %c, double %a, double %b
   ret double %1
Index: llvm/test/CodeGen/ARM/select.ll
===================================================================
--- llvm/test/CodeGen/ARM/select.ll
+++ llvm/test/CodeGen/ARM/select.ll
@@ -65,7 +65,7 @@
 ;CHECK: movmi
 ;CHECK: movpl
 ;CHECK-VFP-LABEL: f7:
-;CHECK-VFP: vmovmi
+;CHECK-VFP: vldrmi
     %tmp = fcmp olt double %a, 1.234e+00
     %tmp1 = select i1 %tmp, double -1.000e+00, double %b
     ret double %tmp1
@@ -153,3 +153,19 @@
 }
 
 declare { i32, i1 } @llvm.smul.with.overflow.i32(i32, i32)
+
+ at ff = dso_local local_unnamed_addr global double 0x7FEFFFFFFFFFFFFF, align 8
+ at xx = dso_local local_unnamed_addr global i32 16777216, align 4
+
+; CHECK-VFP-LABEL: f13:
+define double @f13() {
+; CHECK-VFP: %bb.1
+; CHECK-VFP-NEXT: vadd
+entry:
+  %0 = load double, double* @ff, align 8
+  %1 = load i32, i32* @xx, align 4
+  %cmp = icmp slt i32 %1, 1048576
+  %mul = fmul double %0, 2.000000e+00
+  %spec.select = select i1 %cmp, double %mul, double %0
+  ret double %spec.select
+}
Index: llvm/lib/Target/ARM/ARMInstrVFP.td
===================================================================
--- llvm/lib/Target/ARM/ARMInstrVFP.td
+++ llvm/lib/Target/ARM/ARMInstrVFP.td
@@ -2320,11 +2320,13 @@
 //
 
 let hasSideEffects = 0 in {
+let usesCustomInserter = 1 in {
 def VMOVDcc  : PseudoInst<(outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm, cmovpred:$p),
                     IIC_fpUNA64,
                     [(set (f64 DPR:$Dd),
                           (ARMcmov DPR:$Dn, DPR:$Dm, cmovpred:$p))]>,
                RegConstraint<"$Dn = $Dd">, Requires<[HasFPRegs64]>;
+}
 
 def VMOVScc  : PseudoInst<(outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm, cmovpred:$p),
                     IIC_fpUNA32,
Index: llvm/lib/Target/ARM/ARMISelLowering.cpp
===================================================================
--- llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -10724,6 +10724,7 @@
     return BB;
   }
 
+  case ARM::VMOVDcc:
   case ARM::tMOVCCr_pseudo: {
     // To "insert" a SELECT_CC instruction, we actually have to insert the
     // diamond control-flow pattern.  The incoming instruction knows the
@@ -10761,8 +10762,9 @@
     BB->addSuccessor(copy0MBB);
     BB->addSuccessor(sinkMBB);
 
-    BuildMI(BB, dl, TII->get(ARM::tBcc))
-        .addMBB(sinkMBB)
+
+    BuildMI(BB, dl,
+           Subtarget->isThumb() ? TII->get(ARM::tBcc) : TII->get(ARM::Bcc))       .addMBB(sinkMBB)
         .addImm(MI.getOperand(3).getImm())
         .addReg(MI.getOperand(4).getReg());
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80468.265901.patch
Type: text/x-patch
Size: 3021 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200524/0da6d289/attachment-0001.bin>


More information about the llvm-commits mailing list