[llvm] [DXIL] Add sign intrinsic part 2 (PR #101988)

Farzon Lotfi via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 14 16:51:34 PDT 2024


================
@@ -293,6 +295,36 @@ static bool expandClampIntrinsic(CallInst *Orig, Intrinsic::ID ClampIntrinsic) {
   return true;
 }
 
+static bool expandSignIntrinsic(CallInst *Orig) {
+  IRBuilder<> Builder(Orig->getParent());
+  Value *X = Orig->getOperand(0);
+  Type *Ty = X->getType();
+  Type *ScalarTy = Ty->getScalarType();
+  Type *RetTy = Orig->getType();
+  Constant *Zero = Constant::getNullValue(Ty);
+  Builder.SetInsertPoint(Orig);
----------------
farzonl wrote:

This looks correct to me and is pretty much what we do in DXC via `HLOperationLower.cpp`'s `TranslateSign`.  A small nitpick I like to keep  the the builder setup code close together ie 
```cpp
 IRBuilder<> Builder(Orig->getParent());
Builder.SetInsertPoint(Orig);
```
Second from the way you are going about it, it looks like you will need a second intrinsic for unsigned sign expansion. so a `Intrinsic::dx_usign` before we can close out the ticket. Is that your understanding aswell?

https://github.com/llvm/llvm-project/pull/101988


More information about the llvm-commits mailing list