Skip to content

Commit 7e0fd77

Browse files
committed
[PowerPC] Fix %llvm.ppc.altivec.vc* lowering
Summary: r372285 changed LLVM to use a `TargetConstant` for parameters of intrinsics that are required to be immediates. Since that commit, use of `%llvm.ppc.altivec.vc{fsx,fux,tsxs,tuxs}` intrinsics has not worked, and resulted in a `LLVM ERROR: Cannot select: intrinsic %llvm.ppc.altivec.vc*` error. The intrinsics' TableGen definitions matched on `imm` instead of `timm`. This commit updates those definitions to use `timm`. Fixes: https://llvm.org/PR44239 Reviewers: hfinkel, nemanjai, #powerpc, Jim Reviewed By: Jim Subscribers: qiucf, wuzish, Jim, hiraditya, kbarton, jsji, shchenz, llvm-commits Tags: #llvm Patched by vddvss (Colin Samples). Differential Revision: https://reviews.llvm.org/D71138
1 parent c0143f3 commit 7e0fd77

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

llvm/lib/Target/PowerPC/PPCInstrAltivec.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,19 +523,19 @@ def VANDC : VXForm_1<1092, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
523523
def VCFSX : VXForm_1<842, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
524524
"vcfsx $vD, $vB, $UIMM", IIC_VecFP,
525525
[(set v4f32:$vD,
526-
(int_ppc_altivec_vcfsx v4i32:$vB, imm:$UIMM))]>;
526+
(int_ppc_altivec_vcfsx v4i32:$vB, timm:$UIMM))]>;
527527
def VCFUX : VXForm_1<778, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
528528
"vcfux $vD, $vB, $UIMM", IIC_VecFP,
529529
[(set v4f32:$vD,
530-
(int_ppc_altivec_vcfux v4i32:$vB, imm:$UIMM))]>;
530+
(int_ppc_altivec_vcfux v4i32:$vB, timm:$UIMM))]>;
531531
def VCTSXS : VXForm_1<970, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
532532
"vctsxs $vD, $vB, $UIMM", IIC_VecFP,
533533
[(set v4i32:$vD,
534-
(int_ppc_altivec_vctsxs v4f32:$vB, imm:$UIMM))]>;
534+
(int_ppc_altivec_vctsxs v4f32:$vB, timm:$UIMM))]>;
535535
def VCTUXS : VXForm_1<906, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
536536
"vctuxs $vD, $vB, $UIMM", IIC_VecFP,
537537
[(set v4i32:$vD,
538-
(int_ppc_altivec_vctuxs v4f32:$vB, imm:$UIMM))]>;
538+
(int_ppc_altivec_vctuxs v4f32:$vB, timm:$UIMM))]>;
539539

540540
// Defines with the UIM field set to 0 for floating-point
541541
// to integer (fp_to_sint/fp_to_uint) conversions and integer

llvm/test/CodeGen/PowerPC/pr44239.ll

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu \
2+
; RUN: -verify-machineinstrs < %s | FileCheck %s
3+
4+
define <4 x float> @check_vcfsx(<4 x i32> %a) {
5+
entry:
6+
%0 = tail call <4 x float> @llvm.ppc.altivec.vcfsx(<4 x i32> %a, i32 1)
7+
ret <4 x float> %0
8+
; CHECK-LABEL: check_vcfsx
9+
; CHECK: vcfsx {{[0-9]+}}, {{[0-9]+}}, 1
10+
}
11+
12+
define <4 x float> @check_vcfux(<4 x i32> %a) {
13+
entry:
14+
%0 = tail call <4 x float> @llvm.ppc.altivec.vcfux(<4 x i32> %a, i32 1)
15+
ret <4 x float> %0
16+
; CHECK-LABEL: check_vcfux
17+
; CHECK: vcfux {{[0-9]+}}, {{[0-9]+}}, 1
18+
}
19+
20+
define <4 x i32> @check_vctsxs(<4 x float> %a) {
21+
entry:
22+
%0 = tail call <4 x i32> @llvm.ppc.altivec.vctsxs(<4 x float> %a, i32 1)
23+
ret <4 x i32> %0
24+
; CHECK-LABEL: check_vctsxs
25+
; CHECK: vctsxs {{[0-9]+}}, {{[0-9]+}}, 1
26+
}
27+
28+
define <4 x i32> @check_vctuxs(<4 x float> %a) {
29+
entry:
30+
%0 = tail call <4 x i32> @llvm.ppc.altivec.vctuxs(<4 x float> %a, i32 1)
31+
ret <4 x i32> %0
32+
; CHECK-LABEL: check_vctuxs
33+
; CHECK: vctuxs {{[0-9]+}}, {{[0-9]+}}, 1
34+
}
35+
36+
declare <4 x float> @llvm.ppc.altivec.vcfsx(<4 x i32>, i32 immarg)
37+
declare <4 x float> @llvm.ppc.altivec.vcfux(<4 x i32>, i32 immarg)
38+
declare <4 x i32> @llvm.ppc.altivec.vctsxs(<4 x float>, i32 immarg)
39+
declare <4 x i32> @llvm.ppc.altivec.vctuxs(<4 x float>, i32 immarg)
40+

0 commit comments

Comments
 (0)