[llvm] [SPIR-V] Implement sample and sample_clamp intrinsics for HLSL resources (PR #177234)
Nathan Gauër via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 22 05:33:50 PST 2026
================
@@ -3019,6 +3023,45 @@ Register SPIRVInstructionSelector::buildZerosVal(const SPIRVType *ResType,
return GR.getOrCreateConstInt(0, I, ResType, TII, ZeroAsNull);
}
+bool SPIRVInstructionSelector::isConstantZero(Register Reg) const {
+ auto IsZero = [this](Register Reg) {
+ Register R = Reg;
+ MachineInstr *Def = getDefInstrMaybeConstant(R, MRI);
+ if (!Def)
+ return false;
+
+ if (Def->getOpcode() == SPIRV::OpConstantNull)
+ return true;
+
+ if (Def->getOpcode() == TargetOpcode::G_CONSTANT ||
+ Def->getOpcode() == SPIRV::OpConstantI)
+ return getIConstVal(R, MRI) == 0;
+
+ return false;
+ };
+
+ if (IsZero(Reg))
+ return true;
+
+ MachineInstr *Def = MRI->getVRegDef(Reg);
+ if (!Def)
+ return false;
+
+ if (Def->getOpcode() == TargetOpcode::G_BUILD_VECTOR ||
+ (Def->getOpcode() == TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS &&
----------------
Keenuts wrote:
so if I follow, this function will return true for `0` and `{ 0, 0 }`, but won't return true for `{ { 0, 0 }, { 0, 0 } }`? composite of composite
https://github.com/llvm/llvm-project/pull/177234
More information about the llvm-commits
mailing list