[PATCH] D60208: [X86] Extend boolean arguments to inline-asm according to getBooleanType

Krzysztof Parzyszek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 3 09:09:52 PDT 2019


kparzysz created this revision.
kparzysz added a reviewer: craig.topper.
Herald added a subscriber: eraman.
Herald added a project: LLVM.

Repository:
  rL LLVM

https://reviews.llvm.org/D60208

Files:
  lib/Target/X86/X86ISelLowering.cpp
  test/CodeGen/X86/inline-asm-i-constraint-i1.ll


Index: test/CodeGen/X86/inline-asm-i-constraint-i1.ll
===================================================================
--- /dev/null
+++ test/CodeGen/X86/inline-asm-i-constraint-i1.ll
@@ -0,0 +1,15 @@
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
+
+; Make sure that boolean immediates are properly (zero) extended.
+; CHECK: .Ltmp[[N:[0-9]+]]:
+; CHECK-NEXT: .quad (42+1)-.Ltmp[[N]]
+
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo() #0 {
+entry:
+  tail call void asm sideeffect ".quad 42 + ${0:c} - .\0A\09", "i,~{dirflag},~{fpsr},~{flags}"(i1 true) #0
+  ret i32 1
+}
+
+attributes #0 = { nounwind }
Index: lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- lib/Target/X86/X86ISelLowering.cpp
+++ lib/Target/X86/X86ISelLowering.cpp
@@ -43501,8 +43501,13 @@
   case 'i': {
     // Literal immediates are always ok.
     if (ConstantSDNode *CST = dyn_cast<ConstantSDNode>(Op)) {
-      // Widen to 64 bits here to get it sign extended.
-      Result = DAG.getTargetConstant(CST->getSExtValue(), SDLoc(Op), MVT::i64);
+      bool IsBool = CST->getConstantIntValue()->getBitWidth() == 1;
+      BooleanContent BCont = getBooleanContents(MVT::i64);
+      ISD::NodeType ExtOpc = IsBool ? getExtendForContent(BCont)
+                                    : ISD::SIGN_EXTEND;
+      int64_t ExtVal = ExtOpc == ISD::ZERO_EXTEND ? CST->getZExtValue()
+                                                  : CST->getSExtValue();
+      Result = DAG.getTargetConstant(ExtVal, SDLoc(Op), MVT::i64);
       break;
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60208.193517.patch
Type: text/x-patch
Size: 1604 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190403/e9a69a37/attachment.bin>


More information about the llvm-commits mailing list