[PATCH] D34303: [InstCombine] Make FPMathOperator working with ConstantExpression
Davide Italiano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 16 16:40:50 PDT 2017
davide created this revision.
Fixes https://bugs.llvm.org//show_bug.cgi?id=33396
https://reviews.llvm.org/D34303
Files:
include/llvm/IR/Operator.h
test/Transforms/InstCombine/pr33453.ll
Index: test/Transforms/InstCombine/pr33453.ll
===================================================================
--- /dev/null
+++ 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
+
+ at g1 = external global i16
+ at 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)
Index: include/llvm/IR/Operator.h
===================================================================
--- include/llvm/IR/Operator.h
+++ include/llvm/IR/Operator.h
@@ -328,8 +328,15 @@
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)));
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34303.102903.patch
Type: text/x-patch
Size: 1661 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170616/fea526f3/attachment.bin>
More information about the llvm-commits
mailing list