From a333049e1742e40a6bb1906bc70429bb8493eec1 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 12 Apr 2019 07:34:30 +0000 Subject: [PATCH] [ConstantFold] Don't evaluate FP or FP vector casts or truncations when simplifying icmp Fix PR41476 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358262 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/ConstantFold.cpp | 2 +- test/Transforms/InstSimplify/bitcast-vector-fold.ll | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/IR/ConstantFold.cpp b/lib/IR/ConstantFold.cpp index 3c01a482a44..1dfd5284a97 100644 --- a/lib/IR/ConstantFold.cpp +++ b/lib/IR/ConstantFold.cpp @@ -1574,7 +1574,7 @@ static ICmpInst::Predicate evaluateICmpRelation(Constant *V1, Constant *V2, 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 diff --git a/test/Transforms/InstSimplify/bitcast-vector-fold.ll b/test/Transforms/InstSimplify/bitcast-vector-fold.ll index c8c390ea6be..608c95688f3 100644 --- a/test/Transforms/InstSimplify/bitcast-vector-fold.ll +++ b/test/Transforms/InstSimplify/bitcast-vector-fold.ll @@ -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> to i64), i64 0)> +; + %ret = icmp eq <1 x i64> to i64)>, zeroinitializer + ret <1 x i1> %ret +} + ; from MultiSource/Benchmarks/Bullet define <2 x float> @foo() { ; CHECK-LABEL: @foo( -- 2.50.1