[PATCH] D34303: [InstCombine] Make FPMathOperator working with ConstantExpression

Davide Italiano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 16 17:08:04 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL305618: [InstCombine] Make FPMathOperator working with ConstantExpression(s). (authored by davide).

Changed prior to commit:
  https://reviews.llvm.org/D34303?vs=102903&id=102910#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34303

Files:
  llvm/trunk/include/llvm/IR/Operator.h
  llvm/trunk/test/Transforms/InstCombine/pr33453.ll


Index: llvm/trunk/include/llvm/IR/Operator.h
===================================================================
--- llvm/trunk/include/llvm/IR/Operator.h
+++ llvm/trunk/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)));
   }
 };
 
Index: llvm/trunk/test/Transforms/InstCombine/pr33453.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/pr33453.ll
+++ llvm/trunk/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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34303.102910.patch
Type: text/x-patch
Size: 1756 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170617/6873859b/attachment.bin>


More information about the llvm-commits mailing list