mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-26 05:32:25 +00:00
fc22bfd921
This patch enables the vec_vsx_ld and vec_vsx_st intrinsics for PowerPC, which provide programmer access to the lxvd2x, lxvw4x, stxvd2x, and stxvw4x instructions. New LLVM intrinsics are provided to represent these four instructions in IntrinsicsPowerPC.td. These are patterned after the similar intrinsics for lvx and stvx (Altivec). In PPCInstrVSX.td, these intrinsics are tied to the code gen patterns, with additional patterns to allow plain vanilla loads and stores to still generate these instructions. At -O1 and higher the intrinsics are immediately converted to loads and stores in InstCombineCalls.cpp. This will open up more optimization opportunities while still allowing the correct instructions to be generated. (Similar code exists for aligned Altivec loads and stores.) The new intrinsics are added to the code that checks for consecutive loads and stores in PPCISelLowering.cpp, as well as to PPCTargetLowering::getTgtMemIntrinsic(). There's a new test to verify the correct instructions are generated. The loads and stores tend to be reordered, so the test just counts their number. It runs at -O2, as it's not very effective to test this at -O0, when many unnecessary loads and stores are generated. I ended up having to modify vsx-fma-m.ll. It turns out this test case is slightly unreliable, but I don't know a good way to prevent problems with it. The xvmaddmdp instructions read and write the same register, which is one of the multiplicands. Commutativity allows either to be chosen. If the FMAs are reordered differently than expected by the test, the register assignment can be different as a result. Hopefully this doesn't change often. There is a companion patch for Clang. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221767 91177308-0d34-0410-b5e6-96231b3b80d8
45 lines
1.7 KiB
LLVM
45 lines
1.7 KiB
LLVM
; Verify that we can create unaligned loads and stores from VSX intrinsics.
|
|
|
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
|
|
|
target triple = "powerpc64-unknown-linux-gnu"
|
|
|
|
@vf = common global <4 x float> zeroinitializer, align 1
|
|
@res_vf = common global <4 x float> zeroinitializer, align 1
|
|
@vd = common global <2 x double> zeroinitializer, align 1
|
|
@res_vd = common global <2 x double> zeroinitializer, align 1
|
|
|
|
define void @test1() {
|
|
entry:
|
|
%t1 = alloca <4 x float>*, align 8
|
|
%t2 = alloca <2 x double>*, align 8
|
|
store <4 x float>* @vf, <4 x float>** %t1, align 8
|
|
%0 = load <4 x float>** %t1, align 8
|
|
%1 = bitcast <4 x float>* %0 to i8*
|
|
%2 = call <4 x i32> @llvm.ppc.vsx.lxvw4x(i8* %1)
|
|
store <4 x float>* @res_vf, <4 x float>** %t1, align 8
|
|
%3 = load <4 x float>** %t1, align 8
|
|
%4 = bitcast <4 x float>* %3 to i8*
|
|
call void @llvm.ppc.vsx.stxvw4x(<4 x i32> %2, i8* %4)
|
|
store <2 x double>* @vd, <2 x double>** %t2, align 8
|
|
%5 = load <2 x double>** %t2, align 8
|
|
%6 = bitcast <2 x double>* %5 to i8*
|
|
%7 = call <2 x double> @llvm.ppc.vsx.lxvd2x(i8* %6)
|
|
store <2 x double>* @res_vd, <2 x double>** %t2, align 8
|
|
%8 = load <2 x double>** %t2, align 8
|
|
%9 = bitcast <2 x double>* %8 to i8*
|
|
call void @llvm.ppc.vsx.stxvd2x(<2 x double> %7, i8* %9)
|
|
ret void
|
|
}
|
|
|
|
; CHECK-LABEL: @test1
|
|
; CHECK: %0 = load <4 x i32>* bitcast (<4 x float>* @vf to <4 x i32>*), align 1
|
|
; CHECK: store <4 x i32> %0, <4 x i32>* bitcast (<4 x float>* @res_vf to <4 x i32>*), align 1
|
|
; CHECK: %1 = load <2 x double>* @vd, align 1
|
|
; CHECK: store <2 x double> %1, <2 x double>* @res_vd, align 1
|
|
|
|
declare <4 x i32> @llvm.ppc.vsx.lxvw4x(i8*)
|
|
declare void @llvm.ppc.vsx.stxvw4x(<4 x i32>, i8*)
|
|
declare <2 x double> @llvm.ppc.vsx.lxvd2x(i8*)
|
|
declare void @llvm.ppc.vsx.stxvd2x(<2 x double>, i8*)
|