@@ -1169,20 +1169,20 @@ Value *SPIRVToLLVM::transShiftLogicalBitwiseInst(SPIRVValue *BV, BasicBlock *BB,
11691169 OP = IntBoolOpMap::rmap (OP);
11701170 BO = static_cast <Instruction::BinaryOps>(OpCodeMap::rmap (OP));
11711171
1172- auto *Op0Constant = dyn_cast<Constant>( transValue (BBN->getOperand (0 ), F, BB) );
1173- auto *Op1Constant = dyn_cast<Constant>( transValue (BBN->getOperand (1 ), F, BB) );
1174- if (Op0Constant && Op1Constant) {
1175- // If both operands are constant, create a constant expression.
1176- // This can be used for initializers.
1177- return ConstantExpr::get (BO, Op0Constant, Op1Constant );
1172+ Value *Op0 = transValue (BBN->getOperand (0 ), F, BB);
1173+ Value *Op1 = transValue (BBN->getOperand (1 ), F, BB);
1174+
1175+ IRBuilder<> Builder (*Context);
1176+ if (BB) {
1177+ Builder. SetInsertPoint (BB );
11781178 }
1179- assert (BB && " Invalid BB " );
1180- auto *Inst = BinaryOperator::Create (BO, transValue (BBN-> getOperand ( 0 ), F, BB),
1181- transValue (BBN-> getOperand ( 1 ), F, BB),
1182- BV-> getName (), BB );
1183- applyNoIntegerWrapDecorations (BV, Inst);
1184- applyFPFastMathModeDecorations (BV, Inst);
1185- return Inst ;
1179+
1180+ Value *NewOp = Builder. CreateBinOp (BO, Op0, Op1, BV-> getName ());
1181+ if ( auto *Inst = dyn_cast<Instruction>(NewOp)) {
1182+ applyNoIntegerWrapDecorations (BV, Inst );
1183+ applyFPFastMathModeDecorations (BV, Inst);
1184+ }
1185+ return NewOp ;
11861186}
11871187
11881188Instruction *SPIRVToLLVM::transCmpInst (SPIRVValue *BV, BasicBlock *BB,
0 commit comments