[clang] [llvm] Add normalize builtins and normalize HLSL function to DirectX and SPIR-V backend (PR #102683)
Farzon Lotfi via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 11 17:07:25 PDT 2024
================
@@ -18584,6 +18584,29 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
CGM.getHLSLRuntime().getLengthIntrinsic(), ArrayRef<Value *>{X},
nullptr, "hlsl.length");
}
+ case Builtin::BI__builtin_hlsl_normalize: {
+ Value *X = EmitScalarExpr(E->getArg(0));
+
+ assert(E->getArg(0)->getType()->hasFloatingRepresentation() &&
+ "normalize operand must have a float representation");
+
+ // scalar inputs should expect a scalar return type
+ if (!E->getArg(0)->getType()->isVectorType())
+ return Builder.CreateIntrinsic(
+ /*ReturnType=*/X->getType()->getScalarType(),
----------------
farzonl wrote:
the conditional block is `!E->getArg(0)->getType()->isVectorType()` why are you looking up getScalarType? `getType` should be sufficent?
https://github.com/llvm/llvm-project/pull/102683
More information about the llvm-commits
mailing list