Skip to content

Commit 6ec845b

Browse files
committed
patch
1 parent f4ef94a commit 6ec845b

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,15 @@
3434
#include "llvm/IR/IntrinsicsSPIRV.h"
3535
#include "llvm/Support/Debug.h"
3636
#include "llvm/Support/ErrorHandling.h"
37-
3837
#define DEBUG_TYPE "spirv-isel"
38+
#ifdef _MSC_VER
39+
#define NO_OPTIMIZE __pragma(optimize("", off))
40+
#elif defined(__GNUC__) || defined(__clang__)
41+
#define NO_OPTIMIZE __attribute__((optimize("O0")))
42+
#else
43+
#define NO_OPTIMIZE
44+
#endif
45+
3946

4047
using namespace llvm;
4148
namespace CL = SPIRV::OpenCLExtInst;
@@ -4127,22 +4134,25 @@ bool SPIRVInstructionSelector::selectIsFpclass(Register ResVReg, const SPIRVType
41274134
}
41284135

41294136

4130-
//Instruction Template
4137+
// Instruction Template
41314138
auto instructionTemplate = [&](unsigned Opcode, SPIRVType* DestType, SPIRVType* ReturnType, auto&&... args) -> Register {
41324139
Register result = MRI->createVirtualRegister(GR.getRegClass(DestType));
41334140
auto &Instr = MIRBuilder.buildInstr(Opcode)
41344141
.addDef(result)
41354142
.addUse(GR.getSPIRVTypeID(DestType));
4136-
4137-
([&](auto&& arg) __attribute__((optimize("O0"))) {
4138-
if(std::is_integral_v<std::decay_t<decltype(arg)>>) {
4139-
Instr.addImm(arg);
4140-
}else{
4141-
Instr.addUse(arg);
4142-
}
4143-
}(args), ...);
4143+
4144+
(void)std::initializer_list<int>{
4145+
([&](auto&& arg) NO_OPTIMIZE {
4146+
if constexpr (std::is_integral_v<std::decay_t<decltype(arg)>>) {
4147+
Instr.addImm(arg);
4148+
} else {
4149+
Instr.addUse(arg);
4150+
}
4151+
}(args), 0)...
4152+
};
41444153
return result;
41454154
};
4155+
41464156
//function to check if the sign bit is set or not
41474157
//1 sign is set if 0 sign is not set
41484158
//inf && sign == 1 then -ve infinity
@@ -4298,7 +4308,7 @@ bool SPIRVInstructionSelector::selectIsFpclass(Register ResVReg, const SPIRVType
42984308
}
42994309
//check if the number is Zero
43004310
if(FPClass & fcZero){
4301-
auto SetUpCMPToZero = [&](Register BitCastToInt,
4311+
auto SetUpCMPToZero = [&, bitWidth](Register BitCastToInt,
43024312
bool IsPositive) -> Register {
43034313
APInt ZeroInt = APInt::getZero(bitWidth);
43044314
Register constantZero;

0 commit comments

Comments
 (0)