|
41 | 41 | #include "llvm/ADT/SmallPtrSet.h" |
42 | 42 | #include "llvm/ADT/StringExtras.h" |
43 | 43 | #include "llvm/Analysis/ValueTracking.h" |
| 44 | +#include "llvm/IR/Constants.h" |
44 | 45 | #include "llvm/IR/DataLayout.h" |
45 | 46 | #include "llvm/IR/InlineAsm.h" |
| 47 | +#include "llvm/IR/InstrTypes.h" |
46 | 48 | #include "llvm/IR/Intrinsics.h" |
47 | 49 | #include "llvm/IR/IntrinsicsAArch64.h" |
48 | 50 | #include "llvm/IR/IntrinsicsAMDGPU.h" |
|
55 | 57 | #include "llvm/IR/IntrinsicsR600.h" |
56 | 58 | #include "llvm/IR/IntrinsicsRISCV.h" |
57 | 59 | #include "llvm/IR/IntrinsicsS390.h" |
| 60 | +#include "llvm/IR/IntrinsicsSPIRV.h" |
58 | 61 | #include "llvm/IR/IntrinsicsVE.h" |
59 | 62 | #include "llvm/IR/IntrinsicsWebAssembly.h" |
60 | 63 | #include "llvm/IR/IntrinsicsX86.h" |
61 | 64 | #include "llvm/IR/MDBuilder.h" |
62 | 65 | #include "llvm/IR/MatrixBuilder.h" |
63 | 66 | #include "llvm/IR/MemoryModelRelaxationAnnotations.h" |
| 67 | +#include "llvm/IR/Type.h" |
64 | 68 | #include "llvm/Support/AMDGPUAddrSpace.h" |
65 | 69 | #include "llvm/Support/ConvertUTF.h" |
66 | 70 | #include "llvm/Support/MathExtras.h" |
@@ -101,13 +105,28 @@ static void initializeAlloca(CodeGenFunction &CGF, AllocaInst *AI, Value *Size, |
101 | 105 |
|
102 | 106 | static Value *handleHlslClip(const CallExpr *E, CodeGenFunction *CGF) { |
103 | 107 | Value *Op0 = CGF->EmitScalarExpr(E->getArg(0)); |
104 | | - auto *CMP = CGF->Builder.CreateFCmpOLT( |
105 | | - Op0, ConstantFP::get(CGF->Builder.getFloatTy(), 0.0)); |
| 108 | + |
| 109 | + Constant *FZeroConst = ConstantFP::getZero(CGF->FloatTy); |
| 110 | + Value *CMP; |
| 111 | + |
| 112 | + if (const auto *VecTy = E->getArg(0)->getType()->getAs<clang::VectorType>()) { |
| 113 | + FZeroConst = ConstantVector::getSplat( |
| 114 | + ElementCount::getFixed(VecTy->getNumElements()), FZeroConst); |
| 115 | + CMP = CGF->Builder.CreateFCmpOLT(Op0, FZeroConst); |
| 116 | + } else |
| 117 | + CMP = CGF->Builder.CreateFCmpOLT(Op0, FZeroConst); |
106 | 118 |
|
107 | 119 | if (CGF->CGM.getTarget().getTriple().isDXIL()) |
108 | 120 | return CGF->Builder.CreateIntrinsic(CGF->VoidTy, llvm::Intrinsic::dx_clip, |
109 | 121 | {CMP}, nullptr); |
110 | 122 |
|
| 123 | + if (const auto *VecTy = E->getArg(0)->getType()->getAs<clang::VectorType>()){ |
| 124 | + |
| 125 | + CMP = CGF->Builder.CreateIntrinsic(CGF->Builder.getInt1Ty(), llvm::Intrinsic::spv_any, |
| 126 | + {CMP}, nullptr); |
| 127 | + } |
| 128 | + |
| 129 | + |
111 | 130 | BasicBlock *LT0 = CGF->createBasicBlock("lt0", CGF->CurFn); |
112 | 131 | BasicBlock *End = CGF->createBasicBlock("end", CGF->CurFn); |
113 | 132 |
|
|
0 commit comments