[llvm] r367766 - [x86] change free truncate hook to handle only simple types (PR42880)

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 3 14:46:27 PDT 2019


Author: spatel
Date: Sat Aug  3 14:46:27 2019
New Revision: 367766

URL: http://llvm.org/viewvc/llvm-project?rev=367766&view=rev
Log:
[x86] change free truncate hook to handle only simple types (PR42880)

This avoids the crash from:
https://bugs.llvm.org/show_bug.cgi?id=42880
...and I think it's a proper constraint for the TLI hook.

But that example raises questions about what happens to get us
into this situation (created i29 types) and what happens later
(why does legalization die on those types), so I'm not sure if
we will resolve the bug based on this change.

Modified:
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
    llvm/trunk/test/CodeGen/X86/shift-combine.ll

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=367766&r1=367765&r2=367766&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sat Aug  3 14:46:27 2019
@@ -28842,6 +28842,8 @@ bool X86TargetLowering::isLegalStoreImme
 bool X86TargetLowering::isTruncateFree(EVT VT1, EVT VT2) const {
   if (!VT1.isInteger() || !VT2.isInteger())
     return false;
+  if (!VT1.isSimple() || !VT2.isSimple())
+    return false;
   unsigned NumBits1 = VT1.getSizeInBits();
   unsigned NumBits2 = VT2.getSizeInBits();
   return NumBits1 > NumBits2;

Modified: llvm/trunk/test/CodeGen/X86/shift-combine.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/shift-combine.ll?rev=367766&r1=367765&r2=367766&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/shift-combine.ll (original)
+++ llvm/trunk/test/CodeGen/X86/shift-combine.ll Sat Aug  3 14:46:27 2019
@@ -387,3 +387,36 @@ define i32 @ashr_add_shl_i32_i8_extra_us
   %conv1 = ashr i32 %sext, 24
   ret i32 %conv1
 }
+
+%"class.QPainterPath" = type { double, double, i32 }
+
+define void @PR42880(i32 %t0) {
+; X32-LABEL: PR42880:
+; X32:       # %bb.0:
+; X32-NEXT:    xorl %eax, %eax
+; X32-NEXT:    testb %al, %al
+; X32-NEXT:    je .LBB16_1
+; X32-NEXT:  # %bb.2: # %if
+; X32-NEXT:  .LBB16_1: # %then
+;
+; X64-LABEL: PR42880:
+; X64:       # %bb.0:
+; X64-NEXT:    xorl %eax, %eax
+; X64-NEXT:    testb %al, %al
+; X64-NEXT:    je .LBB16_1
+; X64-NEXT:  # %bb.2: # %if
+; X64-NEXT:  .LBB16_1: # %then
+  %sub = add nsw i32 %t0, -1
+  %add.ptr.i94 = getelementptr inbounds %"class.QPainterPath", %"class.QPainterPath"* null, i32 %sub
+  %x = ptrtoint %"class.QPainterPath"* %add.ptr.i94 to i32
+  %sub2 = sub i32 %x, 0
+  %div = sdiv exact i32 %sub2, 24
+  br i1 undef, label %if, label %then
+
+then:
+  %t1 = xor i32 %div, -1
+  unreachable
+
+if:
+  unreachable
+}




More information about the llvm-commits mailing list