[llvm] r358262 - [ConstantFold] Don't evaluate FP or FP vector casts or truncations when simplifying icmp

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 12 00:34:31 PDT 2019


Author: maskray
Date: Fri Apr 12 00:34:30 2019
New Revision: 358262

URL: http://llvm.org/viewvc/llvm-project?rev=358262&view=rev
Log:
[ConstantFold] Don't evaluate FP or FP vector casts or truncations when simplifying icmp

Fix PR41476

Modified:
    llvm/trunk/lib/IR/ConstantFold.cpp
    llvm/trunk/test/Transforms/InstSimplify/bitcast-vector-fold.ll

Modified: llvm/trunk/lib/IR/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/ConstantFold.cpp?rev=358262&r1=358261&r2=358262&view=diff
==============================================================================
--- llvm/trunk/lib/IR/ConstantFold.cpp (original)
+++ llvm/trunk/lib/IR/ConstantFold.cpp Fri Apr 12 00:34:30 2019
@@ -1574,7 +1574,7 @@ static ICmpInst::Predicate evaluateICmpR
     case Instruction::ZExt:
     case Instruction::SExt:
       // We can't evaluate floating point casts or truncations.
-      if (CE1Op0->getType()->isFloatingPointTy())
+      if (CE1Op0->getType()->isFPOrFPVectorTy())
         break;
 
       // If the cast is not actually changing bits, and the second operand is a

Modified: llvm/trunk/test/Transforms/InstSimplify/bitcast-vector-fold.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/bitcast-vector-fold.ll?rev=358262&r1=358261&r2=358262&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/bitcast-vector-fold.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/bitcast-vector-fold.ll Fri Apr 12 00:34:30 2019
@@ -74,6 +74,14 @@ define <4 x i32> @test9(<1 x i64> %y) {
   ret <4 x i32> %c
 }
 
+define <1 x i1> @test10() {
+; CHECK-LABEL: @test10(
+; CHECK-NEXT:    ret <1 x i1> <i1 icmp eq (i64 bitcast (<1 x double> <double 0xFFFFFFFFFFFFFFFF> to i64), i64 0)>
+;
+  %ret = icmp eq <1 x i64> <i64 bitcast (<1 x double> <double 0xFFFFFFFFFFFFFFFF> to i64)>, zeroinitializer
+  ret <1 x i1> %ret
+}
+
 ; from MultiSource/Benchmarks/Bullet
 define <2 x float> @foo() {
 ; CHECK-LABEL: @foo(




More information about the llvm-commits mailing list