[llvm] r305618 - [InstCombine] Make FPMathOperator working with ConstantExpression(s).

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 16 17:07:23 PDT 2017


Author: davide
Date: Fri Jun 16 19:07:22 2017
New Revision: 305618

URL: http://llvm.org/viewvc/llvm-project?rev=305618&view=rev
Log:
[InstCombine] Make FPMathOperator working with ConstantExpression(s).

Fixes PR33453.

Differential Revision:  https://reviews.llvm.org/D34303

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

Modified: llvm/trunk/include/llvm/IR/Operator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Operator.h?rev=305618&r1=305617&r2=305618&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Operator.h (original)
+++ llvm/trunk/include/llvm/IR/Operator.h Fri Jun 16 19:07:22 2017
@@ -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)));
   }
 };
 

Added: llvm/trunk/test/Transforms/InstCombine/pr33453.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/pr33453.ll?rev=305618&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/pr33453.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/pr33453.ll Fri Jun 16 19:07:22 2017
@@ -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)




More information about the llvm-commits mailing list