[llvm] [DirectX] legalize usub.sat (PR #135288)

Farzon Lotfi via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 10 18:41:34 PDT 2025


================
@@ -65,12 +65,27 @@ static bool isIntrinsicExpansion(Function &F) {
   case Intrinsic::dx_sign:
   case Intrinsic::dx_step:
   case Intrinsic::dx_radians:
+  case Intrinsic::usub_sat:
   case Intrinsic::vector_reduce_add:
   case Intrinsic::vector_reduce_fadd:
     return true;
   }
   return false;
 }
+
+static Value *expandUsubSat(CallInst *Orig) {
+  Value *A = Orig->getArgOperand(0);
+  Value *B = Orig->getArgOperand(1);
+  Type *Ty = A->getType();
+
+  IRBuilder<> Builder(Orig);
+
+  Value *Cmp = Builder.CreateICmpULT(A, B, "usub.cmp");
----------------
farzonl wrote:

I was trying to use `sub` as the `cmp` to `select`  and not emit and icmp but that didn't work.

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


More information about the llvm-commits mailing list