[PATCH] D18528: Don't fold double constant to an integer if dest type not integral

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 4 16:56:21 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL265367: Don't fold double constant to an integer if dest type not integral (authored by tejohnson).

Changed prior to commit:
  http://reviews.llvm.org/D18528?vs=52201&id=52639#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18528

Files:
  llvm/trunk/lib/IR/ConstantFold.cpp
  llvm/trunk/test/CodeGen/X86/mmx-bitcast-fold.ll

Index: llvm/trunk/test/CodeGen/X86/mmx-bitcast-fold.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/mmx-bitcast-fold.ll
+++ llvm/trunk/test/CodeGen/X86/mmx-bitcast-fold.ll
@@ -0,0 +1,12 @@
+; RUN: opt -mtriple=x86_64-- -early-cse < %s -S | FileCheck %s
+
+; CHECK: @foo(x86_mmx bitcast (double 0.000000e+00 to x86_mmx))
+
+define void @bar() {
+entry:
+  %0 = bitcast double 0.0 to x86_mmx
+  %1 = call x86_mmx @foo(x86_mmx %0)
+  ret void
+}
+
+declare x86_mmx @foo(x86_mmx)
Index: llvm/trunk/lib/IR/ConstantFold.cpp
===================================================================
--- llvm/trunk/lib/IR/ConstantFold.cpp
+++ llvm/trunk/lib/IR/ConstantFold.cpp
@@ -191,6 +191,10 @@
     if (FP->getType()->isPPC_FP128Ty())
       return nullptr;
 
+    // Make sure dest type is compatible with the folded integer constant.
+    if (!DestTy->isIntegerTy())
+      return nullptr;
+
     return ConstantInt::get(FP->getContext(),
                             FP->getValueAPF().bitcastToAPInt());
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18528.52639.patch
Type: text/x-patch
Size: 1058 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160404/bd488dfa/attachment.bin>


More information about the llvm-commits mailing list