[PATCH] D73194: [FPEnv][ARM] Handle expansion of strict SETCC with legal condition code

John Brawn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 22 07:12:17 PST 2020


john.brawn created this revision.
john.brawn added reviewers: pengfei, uweigand, craig.topper.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: LLVM.

STRICT_FSETCC and STRICT_FSETCCS may need to be expanded either because the condition code is not legal or the opcode itself is not legal. Correctly handle the case where the opcode is not legal but the condition code is legal.

The fp-intrinsics test was already testing this but as the entire test was being XFAILed it wasn't noticed. Un-XFAIL the test and instead leave the cases where we aren't generating the right instruction sequences as FIXME.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73194

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  llvm/test/CodeGen/ARM/fp-intrinsics.ll


Index: llvm/test/CodeGen/ARM/fp-intrinsics.ll
===================================================================
--- llvm/test/CodeGen/ARM/fp-intrinsics.ll
+++ llvm/test/CodeGen/ARM/fp-intrinsics.ll
@@ -8,9 +8,8 @@
 ; hardware being present or absent work as expected (i.e. we get an instruction
 ; when one is available, otherwise a libcall).
 
-; FIXME: Tests fails as various things in CodeGen and Target/ARM need fixing.
-; XFAIL: *
-
+; FIXME: We're not generating the right instructions for some of these
+; operations (see further FIXMEs down below).
 
 ; Single-precision intrinsics
 
@@ -71,7 +70,7 @@
 
 ; CHECK-LABEL: fptoui_f32:
 ; CHECK-NOSP: bl __aeabi_f2uiz
-; CHECK-SP: vcvt.u32.f32
+; FIXME-CHECK-SP: vcvt.u32.f32
 define i32 @fptoui_f32(float %x) #0 {
   %val = call i32 @llvm.experimental.constrained.fptoui.f32(float %x, metadata !"fpexcept.strict") #0
   ret i32 %val
@@ -300,7 +299,7 @@
 
 ; CHECK-LABEL: fptoui_f64:
 ; CHECK-NODP: bl __aeabi_d2uiz
-; CHECK-DP: vcvt.u32.f64
+; FIXME-CHECK-DP: vcvt.u32.f64
 define i32 @fptoui_f64(double %x) #0 {
   %val = call i32 @llvm.experimental.constrained.fptoui.f64(double %x, metadata !"fpexcept.strict") #0
   ret i32 %val
@@ -490,15 +489,15 @@
 
 ; CHECK-LABEL: sitofp_f32_i32:
 ; CHECK-NOSP: bl __aeabi_i2f
-; CHECK-SP: vcvt.f32.s32
+; FIXME-CHECK-SP: vcvt.f32.s32
 define float @sitofp_f32_i32(i32 %x) #0 {
   %val = call float @llvm.experimental.constrained.sitofp.f32.i32(i32 %x, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
   ret float %val
 }
 
 ; CHECK-LABEL: sitofp_f64_i32:
-; CHECK-NODP: bl __aeabi_i2d
-; CHECK-DP: vcvt.f64.s32
+; FIXME-CHECK-NODP: bl __aeabi_i2d
+; FIXME-CHECK-DP: vcvt.f64.s32
 define double @sitofp_f64_i32(i32 %x) #0 {
   %val = call double @llvm.experimental.constrained.sitofp.f64.i32(i32 %x, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
   ret double %val
Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -3667,7 +3667,11 @@
         LegalizeSetCCCondCode(Node->getValueType(0), Tmp1, Tmp2, Tmp3,
                               NeedInvert, dl, Chain, IsSignaling);
 
-    if (Legalized) {
+    // If the condition code can be legalized then we can convert to a SETCC
+    // using that condition code. If we have a strict SETCC the condition code
+    // may already be legal, in which case we similarly convert to a non-strict
+    // SETCC with the condition code we already have.
+    if (Legalized || IsStrict) {
       // If we expanded the SETCC by swapping LHS and RHS, or by inverting the
       // condition code, create a new SETCC node.
       if (Tmp3.getNode())
@@ -3686,10 +3690,6 @@
       break;
     }
 
-    // FIXME: It seems Legalized is false iff CCCode is Legal. I don't
-    // understand if this code is useful for strict nodes.
-    assert(!IsStrict && "Don't know how to expand for strict nodes.");
-
     // Otherwise, SETCC for the given comparison type must be completely
     // illegal; expand it into a SELECT_CC.
     EVT VT = Node->getValueType(0);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73194.239584.patch
Type: text/x-patch
Size: 3194 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200122/ea3cb020/attachment.bin>


More information about the llvm-commits mailing list