[PATCH] D51145: make copyFMF consistent with AnyDefined for detection of any FMF flag set to true
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 11 09:41:07 PDT 2018
spatel added inline comments.
================
Comment at: include/llvm/IR/Operator.h:394-395
static bool classof(const Value *V) {
return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
(isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
}
----------------
I don't see the benefit of treating Instruction/ConstantExpr separately when the logic is identical for both and likely to keep growing.
Ie, can we do this:
```
static bool classof(const Value *V) {
unsigned Opcode;
if (auto *I = dyn_cast<Instruction>(V))
Opcode = I->getOpcode();
else if (auto *CE = dyn_cast<ConstantExpr>(V))
Opcode = CE->getOpcode();
else
return false;
switch (Opcode) {
case Instruction::FCmp:
return true;
// Vector operators may have FP type, but they don't do math.
case Instruction::ExtractElement:
case Instruction::ShuffleVector:
case Instruction::InsertElement:
return false;
default:
return V->getType()->isFPOrFPVectorTy();
}
}
```
https://reviews.llvm.org/D51145
More information about the llvm-commits
mailing list