[PATCH] D124509: [RISCV] Fix int16 -> __fp16 conversion code gen

Craig Topper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 27 22:46:59 PDT 2022


craig.topper added a comment.

I'm not opposed to this patch, but here's some additional info

I think this is failing because we hit this code in CGExprScalar.cpp. Where SrcTy and DstTy are both i16 when using the conversion intrinsics.

  // Ignore conversions like int -> uint.
  if (SrcTy == DstTy) {
    llvm::dbgs() << "ctopper20\n";
    if (Opts.EmitImplicitIntegerSignChangeChecks)
      EmitIntegerSignChangeCheck(Src, NoncanonicalSrcType, Src,
                                 NoncanonicalDstType, Loc);
  
    return Src;
  }

Something like this seems to fix it.

  diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
  index d3fe04d5a791..62662bf860c2 100644
  --- a/clang/lib/CodeGen/CGExprScalar.cpp
  +++ b/clang/lib/CodeGen/CGExprScalar.cpp
  @@ -1339,7 +1339,7 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType,
     }
   
     // Ignore conversions like int -> uint.
  -  if (SrcTy == DstTy) {
  +  if (SrcTy == DstTy && !DstType->isHalfType()) {
       if (Opts.EmitImplicitIntegerSignChangeChecks)
         EmitIntegerSignChangeCheck(Src, NoncanonicalSrcType, Src,
                                    NoncanonicalDstType, Loc);


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124509/new/

https://reviews.llvm.org/D124509



More information about the cfe-commits mailing list