File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
test/regression/import/fneg Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -375,6 +375,16 @@ void FunctionImporter::translate_instruction(
375
375
} else if (llvm::isa< llvm::SwitchInst >(inst)) {
376
376
// The preprocessor should use the -lowerswitch pass
377
377
throw ImportError (" llvm switch instructions are not supported" );
378
+ } else if (inst->getOpcode () == llvm::Instruction::FNeg) {
379
+ auto * binary_inst =
380
+ llvm::BinaryOperator::Create (llvm::BinaryOperator::FMul,
381
+ llvm::ConstantFP::get (inst->getOperand (0 )
382
+ ->getType (),
383
+ -1.0 ),
384
+ inst->getOperand (0 ));
385
+ inst->replaceAllUsesWith (binary_inst);
386
+ binary_inst->setDebugLoc (inst->getDebugLoc ());
387
+ this ->translate_binary_operator (bb_translation, binary_inst);
378
388
} else {
379
389
std::ostringstream buf;
380
390
buf << " unsupported llvm instruction: " << inst->getOpcodeName () << " [1]" ;
@@ -2023,6 +2033,10 @@ FunctionImporter::TypeHint FunctionImporter::infer_type_hint_use(
2023
2033
return {}; // no hint
2024
2034
} else if (llvm::isa< llvm::ResumeInst >(user)) {
2025
2035
return {}; // no hint
2036
+ } else if (llvm::isa< llvm::Instruction >(user) &&
2037
+ llvm::cast< llvm::Instruction >(user)->getOpcode () ==
2038
+ llvm::Instruction::FNeg) {
2039
+ return {}; // no hint
2026
2040
} else if (llvm::isa< llvm::SelectInst >(user)) {
2027
2041
// The preprocessor should use the -lower-select pass
2028
2042
throw ImportError (" llvm select instructions are not supported" );
Original file line number Diff line number Diff line change
1
+
2
+ int main () {
3
+ float y = 10.0F ;
4
+ return (int )(- y );
5
+ }
Original file line number Diff line number Diff line change
1
+
2
+ int main () {
3
+ double y = 10.0F ;
4
+ return (int )(- y );
5
+ }
You can’t perform that action at this time.
0 commit comments