[PATCH] [ConstantFolding] Fix wrong folding of intrinsic 'convert.from.fp16'.
Ahmed Bougacha
ahmed.bougacha at gmail.com
Thu May 14 08:48:30 PDT 2015
LGTM, thanks!
-Ahmed
================
Comment at: lib/Analysis/ConstantFolding.cpp:1403
@@ +1402,3 @@
+// constant folding intrinsic calls to 'convert_from_fp16'.
+static const fltSemantics &getFloatingPointSemanticFromType(const Type *Ty) {
+ if (Ty->isHalfTy())
----------------
I swear I saw the same construct elsewhere, but I can't find it. Is there a good header where this could go?
================
Comment at: test/Transforms/ConstProp/convert-from-fp16.ll:3-4
@@ +2,4 @@
+
+; Verify that we don't crash with an assertion failure when constant folding
+; a call to intrinsic 'convert.from.fp16' if the return type is not 'float'.
+
----------------
Since this means the code was untested before, what using a non-0 value? For the extension, the significand of the result should look the same, so we can get creative. (but there's no point in testing APFloat again; it's just that 0 is easy to get right the wrong way)
================
Comment at: test/Transforms/ConstProp/convert-from-fp16.ll:7
@@ +6,3 @@
+define float @fold_from_fp16_to_fp32() {
+; CHECK: ret float 0.000000e+00
+entry:
----------------
CHECK-LABEL?
http://reviews.llvm.org/D9771
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list