[llvm] r280689 - ARM: workaround bundled operation predication

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 5 21:00:13 PDT 2016


Author: compnerd
Date: Mon Sep  5 23:00:12 2016
New Revision: 280689

URL: http://llvm.org/viewvc/llvm-project?rev=280689&view=rev
Log:
ARM: workaround bundled operation predication

This is a Windows ARM specific issue.  If the code path in the if conversion
ends up using a relocation which will form a IMAGE_REL_ARM_MOV32T, we end up
with a bundle to ensure that the mov.w/mov.t pair is not split up.  This is
normally fine, however, if the branch is also predicated, then we end up trying
to predicate the bundle.

For now, report a bundle as being unpredicatable.  Although this is false, this
would trigger a failure case previously anyways, so this is no worse.  That is,
there should not be any code which would previously have been if converted and
predicated which would not be now.

Under certain circumstances, it may be possible to "predicate the bundle".  This
would require scanning all bundle instructions, and ensure that the bundle
contains only predicatable instructions, and converting the bundle into an IT
block sequence.  If the bundle is larger than the maximal IT block length (4
instructions), it would require materializing multiple IT blocks from the single
bundle.

Added:
    llvm/trunk/test/CodeGen/ARM/Windows/if-cvt-bundle.ll
Modified:
    llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp

Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=280689&r1=280688&r2=280689&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Mon Sep  5 23:00:12 2016
@@ -575,6 +575,9 @@ bool ARMBaseInstrInfo::isPredicable(Mach
   if (!MI.isPredicable())
     return false;
 
+  if (MI.isBundle())
+    return false;
+
   if (!isEligibleForITBlock(&MI))
     return false;
 

Added: llvm/trunk/test/CodeGen/ARM/Windows/if-cvt-bundle.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/Windows/if-cvt-bundle.ll?rev=280689&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/Windows/if-cvt-bundle.ll (added)
+++ llvm/trunk/test/CodeGen/ARM/Windows/if-cvt-bundle.ll Mon Sep  5 23:00:12 2016
@@ -0,0 +1,24 @@
+; RUN: llc -mtriple thumbv7--windows-itanium -filetype asm -o - %s | FileCheck %s
+
+declare void @llvm.trap()
+declare arm_aapcs_vfpcc zeroext i1 @g()
+
+define arm_aapcs_vfpcc i8* @f() {
+entry:
+  %call = tail call arm_aapcs_vfpcc zeroext i1 @g()
+  br i1 %call, label %if.then, label %if.end
+
+if.then:
+  ret i8* bitcast (i1 ()* @g to i8*)
+
+if.end:
+  tail call void @llvm.trap()
+  unreachable
+}
+
+; CHECK: push.w {r11, lr}
+; CHECK: bl g
+; CHECK: movw [[REG:r[0-9]+]], :lower16:g
+; CHECK: movt [[REG]], :upper16:g
+; CHECK: pop.w {r11, pc}
+




More information about the llvm-commits mailing list