[llvm] r279223 - [CodeGen] Fix a trivial type conversion bug dating back to pre-2008

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 19 01:38:50 PDT 2016


Author: jamesm
Date: Fri Aug 19 03:38:50 2016
New Revision: 279223

URL: http://llvm.org/viewvc/llvm-project?rev=279223&view=rev
Log:
[CodeGen] Fix a trivial type conversion bug dating back to pre-2008

The heuristic above this code is incredibly suspect, but disregarding that it mutates the cast opcode so we need to check the *mutated* opcode later to see if we need to emit an AssertSext or AssertZext node.

Fixes PR29041.

Added:
    llvm/trunk/test/CodeGen/AArch64/fptouint-i8-zext.ll
Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=279223&r1=279222&r2=279223&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Fri Aug 19 03:38:50 2016
@@ -427,7 +427,7 @@ SDValue DAGTypeLegalizer::PromoteIntRes_
   // Assert that the converted value fits in the original type.  If it doesn't
   // (eg: because the value being converted is too big), then the result of the
   // original operation was undefined anyway, so the assert is still correct.
-  return DAG.getNode(N->getOpcode() == ISD::FP_TO_UINT ?
+  return DAG.getNode(NewOpc == ISD::FP_TO_UINT ?
                      ISD::AssertZext : ISD::AssertSext, dl, NVT, Res,
                      DAG.getValueType(N->getValueType(0).getScalarType()));
 }

Added: llvm/trunk/test/CodeGen/AArch64/fptouint-i8-zext.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/fptouint-i8-zext.ll?rev=279223&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/fptouint-i8-zext.ll (added)
+++ llvm/trunk/test/CodeGen/AArch64/fptouint-i8-zext.ll Fri Aug 19 03:38:50 2016
@@ -0,0 +1,15 @@
+; RUN: llc < %s | FileCheck %s
+
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64"
+
+; CHECK-LABEL: float_char_int_func:
+; CHECK: fcvtzs [[A:w[0-9]+]], s0
+; CHECK-NEXT: and w0, [[A]], #0xff
+; CHECK-NEXT: ret
+define i32 @float_char_int_func(float %infloatVal) {
+entry:
+  %conv = fptoui float %infloatVal to i8
+  %conv1 = zext i8 %conv to i32
+  ret i32 %conv1
+}




More information about the llvm-commits mailing list