File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -3340,6 +3340,29 @@ bool NVPTXTargetLowering::splitValueIntoRegisterParts(
33403340 return false ;
33413341}
33423342
3343+ bool llvm::NVPTXTargetLowering::isTruncateFree (EVT FromVT, EVT ToVT) const {
3344+
3345+ if (!FromVT.isSimple () || !ToVT.isSimple ()) {
3346+ return false ;
3347+ }
3348+
3349+ return (FromVT.getSimpleVT () == MVT::i64 && ToVT.getSimpleVT () == MVT::i32 );
3350+ }
3351+
3352+ bool llvm::NVPTXTargetLowering::isZExtFree (EVT FromVT, EVT ToVT) const {
3353+ if (!FromVT.isSimple () || !ToVT.isSimple ()) {
3354+ return false ;
3355+ }
3356+ return (FromVT.getSimpleVT () == MVT::i32 && ToVT.getSimpleVT () == MVT::i64 );
3357+ }
3358+
3359+ bool llvm::NVPTXTargetLowering::isZExtFree (Type *SrcTy, Type *DstTy) const {
3360+ if (!SrcTy->isIntegerTy () || !DstTy->isIntegerTy ())
3361+ return false ;
3362+ return SrcTy->getPrimitiveSizeInBits () == 32 &&
3363+ DstTy->getPrimitiveSizeInBits () == 64 ;
3364+ }
3365+
33433366// This creates target external symbol for a function parameter.
33443367// Name of the symbol is composed from its index and the function name.
33453368// Negative index corresponds to special parameter (unsized array) used for
Original file line number Diff line number Diff line change @@ -616,6 +616,10 @@ class NVPTXTargetLowering : public TargetLowering {
616616 return true ;
617617 }
618618
619+ bool isTruncateFree (EVT FromVT, EVT ToVT) const override ;
620+ bool isZExtFree (EVT FromVT, EVT ToVT) const override ;
621+ bool isZExtFree (Type *SrcTy, Type *DstTy) const override ;
622+
619623private:
620624 const NVPTXSubtarget &STI; // cache the subtarget here
621625 SDValue getParamSymbol (SelectionDAG &DAG, int idx, EVT) const ;
Original file line number Diff line number Diff line change 1+ ; RUN: llc -march=nvptx64 < %s | FileCheck %s
2+
3+ ; Test for truncation from i64 to i32
4+ define i32 @test_trunc_i64_to_i32 (i64 %val ) {
5+ ; CHECK-LABEL: test_trunc_i64_to_i32
6+ ; CHECK: trunc
7+ %trunc = trunc i64 %val to i32
8+ ret i32 %trunc
9+ }
10+
11+ ; Test for zero-extension from i32 to i64
12+ define i64 @test_zext_i32_to_i64 (i32 %val ) {
13+ ; CHECK-LABEL: test_zext_i32_to_i64
14+ ; CHECK: zext
15+ %zext = zext i32 %val to i64
16+ ret i64 %zext
17+ }
You can’t perform that action at this time.
0 commit comments