mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-28 05:46:06 +00:00

This patch legalizes G_ZEXT, G_SEXT, and G_ANYEXT. If the type is a legal mask type, then the instruction is legalized as the element-wise select, where the condition on the select is the mask typed source operand, and the true and false values are 1 or -1 (for zero/any-extension and sign extension) and zero. If the type is a legal integer or vector integer type, then the instruction is marked as legal. The legalization of the extends may introduce a G_SPLAT_VECTOR, which needs to be legalized in this patch for the extend test cases to pass. A G_SPLAT_VECTOR is legal if the vector type is a legal integer or floating point vector type and the source operand is sXLen type. This is because the SelectionDAG patterns only support sXLen typed ISD::SPLAT_VECTORS, and we'd like to reuse those patterns. A G_SPLAT_VECTOR is cutom legalized if it has a legal s1 element vector type and s1 scalar operand. It is legalized to G_VMSET_VL or G_VMCLR_VL if the splat is all ones or all zeros respectivley. In the case of a non-constant mask splat, we legalize by promoting the scalar value to s8. In order to get the s8 element vector back into s1 vector, we use a G_ICMP. In order for the splat vector and extend tests to pass, we also need to legalize G_ICMP in this patch. A G_ICMP is legal if the destination type is a legal bool vector and the LHS and RHS are legal integer vector types.
46 lines
1.5 KiB
YAML
46 lines
1.5 KiB
YAML
#RUN: not --crash llc -o - -mtriple=arm64 -global-isel -run-pass=none -verify-machineinstrs %s 2>&1 | FileCheck %s
|
|
# REQUIRES: aarch64-registered-target
|
|
|
|
---
|
|
name: test_fcmp
|
|
legalized: true
|
|
regBankSelected: false
|
|
selected: false
|
|
tracksRegLiveness: true
|
|
liveins:
|
|
body: |
|
|
bb.0:
|
|
|
|
%0:_(s32) = G_FCONSTANT float 0.0
|
|
%1:_(s32) = G_FCONSTANT float 1.0
|
|
|
|
; Vector result, scalar source
|
|
; CHECK: Bad machine code: Generic vector icmp/fcmp must preserve number of lanes
|
|
%2:_(<2 x s1>) = G_FCMP floatpred(oeq), %0, %1
|
|
|
|
; Scalar result, vector source
|
|
; CHECK: Bad machine code: Generic vector icmp/fcmp must preserve number of lanes
|
|
%3:_(<2 x s32>) = G_IMPLICIT_DEF
|
|
%4:_(<2 x s32>) = G_IMPLICIT_DEF
|
|
%5:_(s1) = G_FCMP floatpred(oeq), %3, %4
|
|
|
|
; mismatched fixed element count
|
|
; CHECK: Bad machine code: Generic vector icmp/fcmp must preserve number of
|
|
%6:_(<2 x s32>) = G_IMPLICIT_DEF
|
|
%7:_(<2 x s32>) = G_IMPLICIT_DEF
|
|
%8:_(<4 x s1>) = G_FCMP floatpred(oeq), %6, %7
|
|
|
|
; mismatched scalable element count
|
|
; CHECK: Bad machine code: Generic vector icmp/fcmp must preserve number of
|
|
%9:_(<vscale x 2 x s32>) = G_IMPLICIT_DEF
|
|
%10:_(<vscale x 2 x s32>) = G_IMPLICIT_DEF
|
|
%11:_(<vscale x 4 x s1>) = G_FCMP floatpred(oeq), %9, %10
|
|
|
|
; mismatched scalar element type
|
|
; CHECK: *** Bad machine code: Type mismatch in generic instruction ***
|
|
%12:_(s32) = G_FCONSTANT float 0.0
|
|
%13:_(s64) = G_FCONSTANT float 1.0
|
|
%14:_(s1) = G_FCMP floatpred(oeq), %12, %13
|
|
|
|
...
|