[llvm] [LLVM][CodeGen] Ensure SystemZTDCPass::convertFCmp only accepts scalar floating point type. (PR #193738)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 23 06:25:09 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-systemz

Author: Paul Walker (paulwalker-arm)

<details>
<summary>Changes</summary>

Fixes https://lab.llvm.org/buildbot/#/builders/117/builds/18799

---
Full diff: https://github.com/llvm/llvm-project/pull/193738.diff


2 Files Affected:

- (modified) llvm/lib/Target/SystemZ/SystemZTDC.cpp (+2-2) 
- (added) llvm/test/CodeGen/SystemZ/tdc-08.ll (+53) 


``````````diff
diff --git a/llvm/lib/Target/SystemZ/SystemZTDC.cpp b/llvm/lib/Target/SystemZ/SystemZTDC.cpp
index 1e254d694e392..1894e71792a3f 100644
--- a/llvm/lib/Target/SystemZ/SystemZTDC.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZTDC.cpp
@@ -123,8 +123,8 @@ void SystemZTDCPass::convertFCmp(CmpInst &I) {
   Value *Op0 = I.getOperand(0);
   auto *Const = dyn_cast<ConstantFP>(I.getOperand(1));
   auto Pred = I.getPredicate();
-  // Only comparisons with consts are interesting.
-  if (!Const)
+  // Only scalar comparisons with consts are interesting.
+  if (!Const || !Const->getType()->isFloatingPointTy())
     return;
   // Compute the smallest normal number (and its negation).
   auto &Sem = Op0->getType()->getFltSemantics();
diff --git a/llvm/test/CodeGen/SystemZ/tdc-08.ll b/llvm/test/CodeGen/SystemZ/tdc-08.ll
new file mode 100644
index 0000000000000..f48b1132de883
--- /dev/null
+++ b/llvm/test/CodeGen/SystemZ/tdc-08.ll
@@ -0,0 +1,53 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc < %s -mtriple=s390x-linux-gnu 2>&1 | FileCheck %s
+
+; Ensure attempting a fcmp->tdc conversion does not crash for vector types.
+define <4 x float> @f1(<4 x float> %x, <4 x float> %a, <4 x float> %b) {
+; CHECK-LABEL: f1:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    # kill: def $f6s killed $f6s def $f6d
+; CHECK-NEXT:    # kill: def $f4s killed $f4s def $f4d
+; CHECK-NEXT:    # kill: def $f2s killed $f2s def $f2d
+; CHECK-NEXT:    # kill: def $f0s killed $f0s def $f0d
+; CHECK-NEXT:    lgdr %r1, %f0
+; CHECK-NEXT:    lgdr %r3, %f2
+; CHECK-NEXT:    lgdr %r0, %f4
+; CHECK-NEXT:    lgdr %r2, %f6
+; CHECK-NEXT:    risbg %r0, %r0, 33, 191, 32
+; CHECK-NEXT:    risbg %r3, %r3, 33, 191, 32
+; CHECK-NEXT:    risbg %r1, %r1, 33, 191, 32
+; CHECK-NEXT:    cfi %r1, 2139095040
+; CHECK-NEXT:    la %r1, 196(%r15)
+; CHECK-NEXT:    je .LBB0_2
+; CHECK-NEXT:  # %bb.1:
+; CHECK-NEXT:    la %r1, 164(%r15)
+; CHECK-NEXT:  .LBB0_2:
+; CHECK-NEXT:    risbg %r2, %r2, 33, 191, 32
+; CHECK-NEXT:    cfi %r3, 2139095040
+; CHECK-NEXT:    la %r3, 204(%r15)
+; CHECK-NEXT:    je .LBB0_4
+; CHECK-NEXT:  # %bb.3:
+; CHECK-NEXT:    la %r3, 172(%r15)
+; CHECK-NEXT:  .LBB0_4:
+; CHECK-NEXT:    cfi %r0, 2139095040
+; CHECK-NEXT:    la %r4, 212(%r15)
+; CHECK-NEXT:    je .LBB0_6
+; CHECK-NEXT:  # %bb.5:
+; CHECK-NEXT:    la %r4, 180(%r15)
+; CHECK-NEXT:  .LBB0_6:
+; CHECK-NEXT:    le %f0, 0(%r1)
+; CHECK-NEXT:    le %f2, 0(%r3)
+; CHECK-NEXT:    le %f4, 0(%r4)
+; CHECK-NEXT:    cfi %r2, 2139095040
+; CHECK-NEXT:    la %r1, 220(%r15)
+; CHECK-NEXT:    je .LBB0_8
+; CHECK-NEXT:  # %bb.7:
+; CHECK-NEXT:    la %r1, 188(%r15)
+; CHECK-NEXT:  .LBB0_8:
+; CHECK-NEXT:    le %f6, 0(%r1)
+; CHECK-NEXT:    br %r14
+  %abs = call <4 x float> @llvm.fabs.v4f32(<4 x float> %x)
+  %cmp = fcmp ult <4 x float> %abs, splat (float 0x7FF0000000000000)
+  %sel = select <4 x i1> %cmp, <4 x float> %a, <4 x float> %b
+  ret <4 x float> %sel
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/193738


More information about the llvm-commits mailing list