[llvm] r354163 - [X86] Fix LowerAsmOutputForConstraint.
Nirav Dave via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 15 12:01:56 PST 2019
Author: niravd
Date: Fri Feb 15 12:01:55 2019
New Revision: 354163
URL: http://llvm.org/viewvc/llvm-project?rev=354163&view=rev
Log:
[X86] Fix LowerAsmOutputForConstraint.
Summary:
Update Flag when generating cc output.
Fixes PR40737.
Reviewers: rnk, nickdesaulniers, craig.topper, spatel
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D58283
Added:
llvm/trunk/test/CodeGen/X86/pr40737.ll
Modified:
llvm/trunk/include/llvm/CodeGen/TargetLowering.h
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.h
Modified: llvm/trunk/include/llvm/CodeGen/TargetLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetLowering.h?rev=354163&r1=354162&r2=354163&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/TargetLowering.h (original)
+++ llvm/trunk/include/llvm/CodeGen/TargetLowering.h Fri Feb 15 12:01:55 2019
@@ -3663,7 +3663,7 @@ public:
SelectionDAG &DAG) const;
// Lower custom output constraints. If invalid, return SDValue().
- virtual SDValue LowerAsmOutputForConstraint(SDValue &Chain, SDValue *Flag,
+ virtual SDValue LowerAsmOutputForConstraint(SDValue &Chain, SDValue &Flag,
SDLoc DL,
const AsmOperandInfo &OpInfo,
SelectionDAG &DAG) const;
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=354163&r1=354162&r2=354163&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Fri Feb 15 12:01:55 2019
@@ -8174,7 +8174,7 @@ void SelectionDAGBuilder::visitInlineAsm
DAG, FuncInfo, getCurSDLoc(), Chain, &Flag, CS.getInstruction());
break;
case TargetLowering::C_Other:
- Val = TLI.LowerAsmOutputForConstraint(Chain, &Flag, getCurSDLoc(),
+ Val = TLI.LowerAsmOutputForConstraint(Chain, Flag, getCurSDLoc(),
OpInfo, DAG);
break;
case TargetLowering::C_Memory:
@@ -8185,7 +8185,6 @@ void SelectionDAGBuilder::visitInlineAsm
// Indirect output manifest as stores. Record output chains.
if (OpInfo.isIndirect) {
-
const Value *Ptr = OpInfo.CallOperandVal;
assert(Ptr && "Expected value CallOperandVal for indirect asm operand");
SDValue Store = DAG.getStore(Chain, getCurSDLoc(), Val, getValue(Ptr),
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=354163&r1=354162&r2=354163&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Fri Feb 15 12:01:55 2019
@@ -3280,7 +3280,7 @@ const char *TargetLowering::LowerXConstr
}
SDValue TargetLowering::LowerAsmOutputForConstraint(
- SDValue &Chain, SDValue *Flag, SDLoc DL, const AsmOperandInfo &OpInfo,
+ SDValue &Chain, SDValue &Flag, SDLoc DL, const AsmOperandInfo &OpInfo,
SelectionDAG &DAG) const {
return SDValue();
}
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=354163&r1=354162&r2=354163&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Feb 15 12:01:55 2019
@@ -42733,7 +42733,7 @@ LowerXConstraint(EVT ConstraintVT) const
// Lower @cc targets via setcc.
SDValue X86TargetLowering::LowerAsmOutputForConstraint(
- SDValue &Chain, SDValue *Flag, SDLoc DL, const AsmOperandInfo &OpInfo,
+ SDValue &Chain, SDValue &Flag, SDLoc DL, const AsmOperandInfo &OpInfo,
SelectionDAG &DAG) const {
X86::CondCode Cond = parseConstraintCode(OpInfo.ConstraintCode);
if (Cond == X86::COND_INVALID)
@@ -42744,14 +42744,13 @@ SDValue X86TargetLowering::LowerAsmOutpu
report_fatal_error("Flag output operand is of invalid type");
// Get EFLAGS register. Only update chain when copyfrom is glued.
- SDValue EFlags;
- if (Flag) {
- EFlags = DAG.getCopyFromReg(Chain, DL, X86::EFLAGS, MVT::i32, *Flag);
- Chain = EFlags.getValue(1);
+ if (Flag.getNode()) {
+ Flag = DAG.getCopyFromReg(Chain, DL, X86::EFLAGS, MVT::i32, Flag);
+ Chain = Flag.getValue(1);
} else
- EFlags = DAG.getCopyFromReg(Chain, DL, X86::EFLAGS, MVT::i32);
+ Flag = DAG.getCopyFromReg(Chain, DL, X86::EFLAGS, MVT::i32);
// Extract CC code.
- SDValue CC = getSETCC(Cond, EFlags, DL, DAG);
+ SDValue CC = getSETCC(Cond, Flag, DL, DAG);
// Extend to 32-bits
SDValue Result = DAG.getNode(ISD::ZERO_EXTEND, DL, OpInfo.ConstraintVT, CC);
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=354163&r1=354162&r2=354163&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Fri Feb 15 12:01:55 2019
@@ -922,7 +922,7 @@ namespace llvm {
}
/// Handle Lowering flag assembly outputs.
- SDValue LowerAsmOutputForConstraint(SDValue &Chain, SDValue *Flag, SDLoc DL,
+ SDValue LowerAsmOutputForConstraint(SDValue &Chain, SDValue &Flag, SDLoc DL,
const AsmOperandInfo &Constraint,
SelectionDAG &DAG) const override;
Added: llvm/trunk/test/CodeGen/X86/pr40737.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pr40737.ll?rev=354163&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/pr40737.ll (added)
+++ llvm/trunk/test/CodeGen/X86/pr40737.ll Fri Feb 15 12:01:55 2019
@@ -0,0 +1,19 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu %s -o - | FileCheck %s
+
+define i8 @_BitScanForward(i32* nocapture %Index, i32 %Mask) {
+; CHECK-LABEL: _BitScanForward:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: #APP
+; CHECK-NEXT: bsfl %esi, %ecx
+; CHECK-NEXT: #NO_APP
+; CHECK-NEXT: setne %al
+; CHECK-NEXT: movl %ecx, (%rdi)
+; CHECK-NEXT: retq
+entry:
+ %0 = tail call { i8, i32 } asm "bsf$(l $2,$1 $| $1,$2$)", "={@ccnz},=r,r,~{dirflag},~{fpsr},~{flags}"(i32 %Mask)
+ %asmresult = extractvalue { i8, i32 } %0, 0
+ %asmresult1 = extractvalue { i8, i32 } %0, 1
+ store i32 %asmresult1, i32* %Index, align 4
+ ret i8 %asmresult
+}
More information about the llvm-commits
mailing list