diff options
| author | Davide Italiano <davide@freebsd.org> | 2017-06-17 00:07:22 +0000 |
|---|---|---|
| committer | Davide Italiano <davide@freebsd.org> | 2017-06-17 00:07:22 +0000 |
| commit | 64f94fe02a172d44dc920e4d2ab80779eaa1f99f (patch) | |
| tree | d60f3dc1773c211ddc8f68e0ef5a66f679683f04 | |
| parent | b0fdd214b76336c8638a27b593f9894e90bae42a (diff) | |
| download | bcm5719-llvm-64f94fe02a172d44dc920e4d2ab80779eaa1f99f.tar.gz bcm5719-llvm-64f94fe02a172d44dc920e4d2ab80779eaa1f99f.zip | |
[InstCombine] Make FPMathOperator working with ConstantExpression(s).
Fixes PR33453.
Differential Revision: https://reviews.llvm.org/D34303
llvm-svn: 305618
| -rw-r--r-- | llvm/include/llvm/IR/Operator.h | 9 | ||||
| -rw-r--r-- | llvm/test/Transforms/InstCombine/pr33453.ll | 15 |
2 files changed, 23 insertions, 1 deletions
diff --git a/llvm/include/llvm/IR/Operator.h b/llvm/include/llvm/IR/Operator.h index 6eb5998478c..c7f4697e93e 100644 --- a/llvm/include/llvm/IR/Operator.h +++ b/llvm/include/llvm/IR/Operator.h @@ -328,8 +328,15 @@ public: return I->getType()->isFPOrFPVectorTy() || I->getOpcode() == Instruction::FCmp; } + + static inline bool classof(const ConstantExpr *CE) { + return CE->getType()->isFPOrFPVectorTy() || + CE->getOpcode() == Instruction::FCmp; + } + static inline bool classof(const Value *V) { - return isa<Instruction>(V) && classof(cast<Instruction>(V)); + return (isa<Instruction>(V) && classof(cast<Instruction>(V))) || + (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V))); } }; diff --git a/llvm/test/Transforms/InstCombine/pr33453.ll b/llvm/test/Transforms/InstCombine/pr33453.ll new file mode 100644 index 00000000000..dee4c5bf566 --- /dev/null +++ b/llvm/test/Transforms/InstCombine/pr33453.ll @@ -0,0 +1,15 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -instcombine -S %s | FileCheck %s + +@g1 = external global i16 +@g2 = external global i16 + +define float @patatino() { +; CHECK-LABEL: @patatino( +; CHECK-NEXT: ret float fmul (float uitofp (i1 icmp eq (i16* getelementptr inbounds (i16, i16* @g2, i64 1), i16* @g1) to float), float uitofp (i1 icmp eq (i16* getelementptr inbounds (i16, i16* @g2, i64 1), i16* @g1) to float)) +; + %call = call float @fabsf(float fmul (float uitofp (i1 icmp eq (i16* getelementptr inbounds (i16, i16* @g2, i64 1), i16* @g1) to float), float uitofp (i1 icmp eq (i16* getelementptr inbounds (i16, i16* @g2, i64 1), i16* @g1) to float))) + ret float %call +} + +declare float @fabsf(float) |

