[PATCH] D84238: [PowerPC] Set v1i128 to expand for SETCC to avoid crash

Zhang Kang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 21 06:51:20 PDT 2020


ZhangKang created this revision.
ZhangKang added reviewers: hfinkel, efriedma, nemanjai, PowerPC.
ZhangKang added a project: LLVM.
Herald added subscribers: shchenz, wuzish, hiraditya.

PPC only supports the instruction selection for `v16i8, v8i16, v4i32, v2i64, v4f32 and v2f64` for ISD::SETCC,
don't support the v1i128, so below IR will crash:

  t35: v1i128 = setcc t47, t74, setult:ch

This patch is to set v1i128 to expand for SETCC to avoid crash. And the expanding can get the expected result.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84238

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/setcc-vector.ll


Index: llvm/test/CodeGen/PowerPC/setcc-vector.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/setcc-vector.ll
@@ -0,0 +1,20 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mcpu=pwr9 -mtriple=powerpc64le-unknown-unknown \
+; RUN:   -ppc-asm-full-reg-names < %s | FileCheck %s
+
+define <2 x i1> @setcc_v1i128([1 x i128] %a) {
+; CHECK-LABEL: setcc_v1i128:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    cmpldi r3, 35708
+; CHECK-NEXT:    cmpdi cr1, r4, 0
+; CHECK-NEXT:    li r3, -1
+; CHECK-NEXT:    crnand 4*cr5+lt, 4*cr1+eq, lt
+; CHECK-NEXT:    isel r3, 0, r3, 4*cr5+lt
+; CHECK-NEXT:    mtvsrdd vs34, 0, r3
+; CHECK-NEXT:    blr
+entry:
+  %b = extractvalue [1 x i128] %a, 0
+  %0 = insertelement <2 x i128> undef, i128 %b, i32 0
+  %1 = icmp ult <2 x i128> %0, <i128 35708, i128 1005868>
+  ret <2 x i1> %1
+}
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -906,6 +906,7 @@
         setOperationAction(ISD::SRL, MVT::v1i128, Expand);
         setOperationAction(ISD::SRA, MVT::v1i128, Expand);
 
+        setOperationAction(ISD::SETCC, MVT::v1i128, Expand);
         setOperationAction(ISD::SETCC, MVT::v2i64, Legal);
       }
       else {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84238.279504.patch
Type: text/x-patch
Size: 1458 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200721/c9293b48/attachment.bin>


More information about the llvm-commits mailing list