<div dir="ltr">Hi Bob,<div><br></div><div>Sorry to know about that. I just committed a fix r218364 to clear <span style="font-family:arial,sans-serif;font-size:14.3999996185303px">PreferredExtendType in function state info.</span><br></div><div><span style="font-family:arial,sans-serif;font-size:14.3999996185303px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:14.3999996185303px">Let me know if you still see memory consumption issue. I tried the original huge case, and I can't see memory issue. </span></div><div><span style="font-family:arial,sans-serif;font-size:14.3999996185303px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:14.3999996185303px">Thanks,</span></div><div><span style="font-family:arial,sans-serif;font-size:14.3999996185303px">-Jiangning</span></div><div><span style="font-family:arial,sans-serif;font-size:14.3999996185303px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-24 1:56 GMT+08:00 Bob Wilson <span dir="ltr"><<a href="mailto:bob.wilson@apple.com" target="_blank">bob.wilson@apple.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We’re seeing significant regressions in memory usage. I think you forgot to clear the PreferredExtendType DenseMap that you added here.<br>
<div class="HOEnZb"><div class="h5"><br>
> On Sep 18, 2014, at 10:30 PM, Jiangning Liu <<a href="mailto:jiangning.liu@arm.com">jiangning.liu@arm.com</a>> wrote:<br>
><br>
> Author: jiangning<br>
> Date: Fri Sep 19 00:30:35 2014<br>
> New Revision: 218101<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=218101&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=218101&view=rev</a><br>
> Log:<br>
> Optimize sext/zext insertion algorithm in back-end.<br>
><br>
> With this optimization, we will not always insert zext for values crossing<br>
> basic blocks, but insert sext if the users of a value crossing basic block<br>
> has preference of sign predicate.<br>
><br>
><br>
> Added:<br>
> llvm/trunk/test/CodeGen/AArch64/rm_redundant_cmp.ll<br>
> Modified:<br>
> llvm/trunk/include/llvm/CodeGen/FunctionLoweringInfo.h<br>
> llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp<br>
> llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp<br>
> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp<br>
> llvm/trunk/test/CodeGen/AArch64/atomic-ops.ll<br>
><br>
> Modified: llvm/trunk/include/llvm/CodeGen/FunctionLoweringInfo.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FunctionLoweringInfo.h?rev=218101&r1=218100&r2=218101&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FunctionLoweringInfo.h?rev=218101&r1=218100&r2=218101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/CodeGen/FunctionLoweringInfo.h (original)<br>
> +++ llvm/trunk/include/llvm/CodeGen/FunctionLoweringInfo.h Fri Sep 19 00:30:35 2014<br>
> @@ -21,6 +21,7 @@<br>
> #include "llvm/ADT/SmallPtrSet.h"<br>
> #include "llvm/ADT/SmallVector.h"<br>
> #include "llvm/CodeGen/MachineBasicBlock.h"<br>
> +#include "llvm/CodeGen/ISDOpcodes.h"<br>
> #include "llvm/IR/InlineAsm.h"<br>
> #include "llvm/IR/Instructions.h"<br>
> #include "llvm/Target/TargetRegisterInfo.h"<br>
> @@ -106,6 +107,10 @@ public:<br>
> KnownZero(1, 0) {}<br>
> };<br>
><br>
> + /// Record the preferred extend type (ISD::SIGN_EXTEND or ISD::ZERO_EXTEND)<br>
> + /// for a value.<br>
> + DenseMap<const Value *, ISD::NodeType> PreferredExtendType;<br>
> +<br>
> /// VisitedBBs - The set of basic blocks visited thus far by instruction<br>
> /// selection.<br>
> SmallPtrSet<const BasicBlock*, 4> VisitedBBs;<br>
><br>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp?rev=218101&r1=218100&r2=218101&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp?rev=218101&r1=218100&r2=218101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp (original)<br>
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp Fri Sep 19 00:30:35 2014<br>
> @@ -56,6 +56,28 @@ static bool isUsedOutsideOfDefiningBlock<br>
> return false;<br>
> }<br>
><br>
> +static ISD::NodeType getPreferredExtendForValue(const Value *V) {<br>
> + // For the users of the source value being used for compare instruction, if<br>
> + // the number of signed predicate is greater than unsigned predicate, we<br>
> + // prefer to use SIGN_EXTEND.<br>
> + //<br>
> + // With this optimization, we would be able to reduce some redundant sign or<br>
> + // zero extension instruction, and eventually more machine CSE opportunities<br>
> + // can be exposed.<br>
> + ISD::NodeType ExtendKind = ISD::ANY_EXTEND;<br>
> + unsigned NumOfSigned = 0, NumOfUnsigned = 0;<br>
> + for (const User *U : V->users()) {<br>
> + if (const auto *CI = dyn_cast<CmpInst>(U)) {<br>
> + NumOfSigned += CI->isSigned();<br>
> + NumOfUnsigned += CI->isUnsigned();<br>
> + }<br>
> + }<br>
> + if (NumOfSigned > NumOfUnsigned)<br>
> + ExtendKind = ISD::SIGN_EXTEND;<br>
> +<br>
> + return ExtendKind;<br>
> +}<br>
> +<br>
> void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,<br>
> SelectionDAG *DAG) {<br>
> const TargetLowering *TLI = TM.getSubtargetImpl()->getTargetLowering();<br>
> @@ -182,6 +204,9 @@ void FunctionLoweringInfo::set(const Fun<br>
> }<br>
> }<br>
> }<br>
> +<br>
> + // Decide the preferred extend type for a value.<br>
> + PreferredExtendType[I] = getPreferredExtendForValue(I);<br>
> }<br>
><br>
> // Create an initial MachineBasicBlock for each LLVM BasicBlock in F. This<br>
><br>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=218101&r1=218100&r2=218101&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=218101&r1=218100&r2=218101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original)<br>
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Fri Sep 19 00:30:35 2014<br>
> @@ -862,7 +862,26 @@ void DAGTypeLegalizer::PromoteSetCCOpera<br>
> switch (CCCode) {<br>
> default: llvm_unreachable("Unknown integer comparison!");<br>
> case ISD::SETEQ:<br>
> - case ISD::SETNE:<br>
> + case ISD::SETNE: {<br>
> + SDValue OpL = GetPromotedInteger(NewLHS);<br>
> + SDValue OpR = GetPromotedInteger(NewRHS);<br>
> +<br>
> + // We would prefer to promote the comparison operand with sign extension,<br>
> + // if we find the operand is actually to truncate an AssertSext. With this<br>
> + // optimization, we can avoid inserting real truncate instruction, which<br>
> + // is redudant eventually.<br>
> + if (OpL->getOpcode() == ISD::AssertSext &&<br>
> + cast<VTSDNode>(OpL->getOperand(1))->getVT() == NewLHS.getValueType() &&<br>
> + OpR->getOpcode() == ISD::AssertSext &&<br>
> + cast<VTSDNode>(OpR->getOperand(1))->getVT() == NewRHS.getValueType()) {<br>
> + NewLHS = OpL;<br>
> + NewRHS = OpR;<br>
> + } else {<br>
> + NewLHS = ZExtPromotedInteger(NewLHS);<br>
> + NewRHS = ZExtPromotedInteger(NewRHS);<br>
> + }<br>
> + break;<br>
> + }<br>
> case ISD::SETUGE:<br>
> case ISD::SETUGT:<br>
> case ISD::SETULE:<br>
><br>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=218101&r1=218100&r2=218101&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=218101&r1=218100&r2=218101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)<br>
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Fri Sep 19 00:30:35 2014<br>
> @@ -646,8 +646,10 @@ namespace {<br>
> /// specified value into the registers specified by this object. This uses<br>
> /// Chain/Flag as the input and updates them for the output Chain/Flag.<br>
> /// If the Flag pointer is NULL, no flag is used.<br>
> - void getCopyToRegs(SDValue Val, SelectionDAG &DAG, SDLoc dl,<br>
> - SDValue &Chain, SDValue *Flag, const Value *V) const;<br>
> + void<br>
> + getCopyToRegs(SDValue Val, SelectionDAG &DAG, SDLoc dl, SDValue &Chain,<br>
> + SDValue *Flag, const Value *V,<br>
> + ISD::NodeType PreferredExtendType = ISD::ANY_EXTEND) const;<br>
><br>
> /// AddInlineAsmOperands - Add this value to the specified inlineasm node<br>
> /// operand list. This adds the code marker, matching input operand index<br>
> @@ -762,9 +764,10 @@ SDValue RegsForValue::getCopyFromRegs(Se<br>
> /// Chain/Flag as the input and updates them for the output Chain/Flag.<br>
> /// If the Flag pointer is NULL, no flag is used.<br>
> void RegsForValue::getCopyToRegs(SDValue Val, SelectionDAG &DAG, SDLoc dl,<br>
> - SDValue &Chain, SDValue *Flag,<br>
> - const Value *V) const {<br>
> + SDValue &Chain, SDValue *Flag, const Value *V,<br>
> + ISD::NodeType PreferredExtendType) const {<br>
> const TargetLowering &TLI = DAG.getTargetLoweringInfo();<br>
> + ISD::NodeType ExtendKind = PreferredExtendType;<br>
><br>
> // Get the list of the values's legal parts.<br>
> unsigned NumRegs = Regs.size();<br>
> @@ -773,8 +776,9 @@ void RegsForValue::getCopyToRegs(SDValue<br>
> EVT ValueVT = ValueVTs[Value];<br>
> unsigned NumParts = TLI.getNumRegisters(*DAG.getContext(), ValueVT);<br>
> MVT RegisterVT = RegVTs[Value];<br>
> - ISD::NodeType ExtendKind =<br>
> - TLI.isZExtFree(Val, RegisterVT)? ISD::ZERO_EXTEND: ISD::ANY_EXTEND;<br>
> +<br>
> + if (ExtendKind == ISD::ANY_EXTEND && TLI.isZExtFree(Val, RegisterVT))<br>
> + ExtendKind = ISD::ZERO_EXTEND;<br>
><br>
> getCopyToParts(DAG, dl, Val.getValue(Val.getResNo() + Value),<br>
> &Parts[Part], NumParts, RegisterVT, V, ExtendKind);<br>
> @@ -7429,7 +7433,12 @@ SelectionDAGBuilder::CopyValueToVirtualR<br>
> const TargetLowering *TLI = TM.getSubtargetImpl()->getTargetLowering();<br>
> RegsForValue RFV(V->getContext(), *TLI, Reg, V->getType());<br>
> SDValue Chain = DAG.getEntryNode();<br>
> - RFV.getCopyToRegs(Op, DAG, getCurSDLoc(), Chain, nullptr, V);<br>
> +<br>
> + ISD::NodeType ExtendType = (FuncInfo.PreferredExtendType.find(V) ==<br>
> + FuncInfo.PreferredExtendType.end())<br>
> + ? ISD::ANY_EXTEND<br>
> + : FuncInfo.PreferredExtendType[V];<br>
> + RFV.getCopyToRegs(Op, DAG, getCurSDLoc(), Chain, nullptr, V, ExtendType);<br>
> PendingExports.push_back(Chain);<br>
> }<br>
><br>
><br>
> Modified: llvm/trunk/test/CodeGen/AArch64/atomic-ops.ll<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/atomic-ops.ll?rev=218101&r1=218100&r2=218101&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/atomic-ops.ll?rev=218101&r1=218100&r2=218101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/test/CodeGen/AArch64/atomic-ops.ll (original)<br>
> +++ llvm/trunk/test/CodeGen/AArch64/atomic-ops.ll Fri Sep 19 00:30:35 2014<br>
> @@ -509,7 +509,7 @@ define i8 @test_atomic_load_min_i8(i8 %o<br>
> ; CHECK-NEXT: cbnz [[STATUS]], .LBB{{[0-9]+}}_1<br>
> ; CHECK-NOT: dmb<br>
><br>
> -; CHECK: mov {{[xw]}}0, {{[xw]}}[[OLD]]<br>
> +; CHECK: mov {{[xw]}}0, {{[xw]}}[[OLD_EXT]]<br>
> ret i8 %old<br>
> }<br>
><br>
> @@ -534,7 +534,7 @@ define i16 @test_atomic_load_min_i16(i16<br>
> ; CHECK-NEXT: cbnz [[STATUS]], .LBB{{[0-9]+}}_1<br>
> ; CHECK-NOT: dmb<br>
><br>
> -; CHECK: mov {{[xw]}}0, {{[xw]}}[[OLD]]<br>
> +; CHECK: mov {{[xw]}}0, {{[xw]}}[[OLD_EXT]]<br>
> ret i16 %old<br>
> }<br>
><br>
> @@ -607,7 +607,7 @@ define i8 @test_atomic_load_max_i8(i8 %o<br>
> ; CHECK-NEXT: cbnz [[STATUS]], .LBB{{[0-9]+}}_1<br>
> ; CHECK-NOT: dmb<br>
><br>
> -; CHECK: mov {{[xw]}}0, {{[xw]}}[[OLD]]<br>
> +; CHECK: mov {{[xw]}}0, {{[xw]}}[[OLD_EXT]]<br>
> ret i8 %old<br>
> }<br>
><br>
> @@ -632,7 +632,7 @@ define i16 @test_atomic_load_max_i16(i16<br>
> ; CHECK-NEXT: cbnz [[STATUS]], .LBB{{[0-9]+}}_1<br>
> ; CHECK-NOT: dmb<br>
><br>
> -; CHECK: mov {{[xw]}}0, {{[xw]}}[[OLD]]<br>
> +; CHECK: mov {{[xw]}}0, {{[xw]}}[[OLD_EXT]]<br>
> ret i16 %old<br>
> }<br>
><br>
><br>
> Added: llvm/trunk/test/CodeGen/AArch64/rm_redundant_cmp.ll<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/rm_redundant_cmp.ll?rev=218101&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/rm_redundant_cmp.ll?rev=218101&view=auto</a><br>
> ==============================================================================<br>
> --- llvm/trunk/test/CodeGen/AArch64/rm_redundant_cmp.ll (added)<br>
> +++ llvm/trunk/test/CodeGen/AArch64/rm_redundant_cmp.ll Fri Sep 19 00:30:35 2014<br>
> @@ -0,0 +1,254 @@<br>
> +; RUN: llc < %s -mtriple=aarch64-linux-gnuabi -O2 | FileCheck %s<br>
> +<br>
> +; The following cases are for i16<br>
> +<br>
> +%struct.s_signed_i16 = type { i16, i16, i16 }<br>
> +%struct.s_unsigned_i16 = type { i16, i16, i16 }<br>
> +<br>
> +@cost_s_i8_i16 = common global %struct.s_signed_i16 zeroinitializer, align 2<br>
> +@cost_u_i16 = common global %struct.s_unsigned_i16 zeroinitializer, align 2<br>
> +<br>
> +define void @test_i16_2cmp_signed_1() {<br>
> +; CHECK-LABEL: test_i16_2cmp_signed_1<br>
> +; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}<br>
> +; CHECK-NEXT: <a href="http://b.gt" target="_blank">b.gt</a><br>
> +; CHECK-NOT: cmp<br>
> +; CHECK: <a href="http://b.ne" target="_blank">b.ne</a><br>
> +entry:<br>
> + %0 = load i16* getelementptr inbounds (%struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 1), align 2<br>
> + %1 = load i16* getelementptr inbounds (%struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 2), align 2<br>
> + %cmp = icmp sgt i16 %0, %1<br>
> + br i1 %cmp, label %if.then, label %if.else<br>
> +<br>
> +if.then: ; preds = %entry<br>
> + store i16 %0, i16* getelementptr inbounds (%struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 0), align 2<br>
> + br label %if.end8<br>
> +<br>
> +if.else: ; preds = %entry<br>
> + %cmp5 = icmp eq i16 %0, %1<br>
> + br i1 %cmp5, label %if.then7, label %if.end8<br>
> +<br>
> +if.then7: ; preds = %if.else<br>
> + store i16 %0, i16* getelementptr inbounds (%struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 0), align 2<br>
> + br label %if.end8<br>
> +<br>
> +if.end8: ; preds = %if.else, %if.then7, %if.then<br>
> + ret void<br>
> +}<br>
> +<br>
> +define void @test_i16_2cmp_signed_2() {<br>
> +; CHECK-LABEL: test_i16_2cmp_signed_2<br>
> +; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}<br>
> +; CHECK-NEXT: b.le<br>
> +; CHECK-NOT: cmp<br>
> +; CHECK: <a href="http://b.ge" target="_blank">b.ge</a><br>
> +entry:<br>
> + %0 = load i16* getelementptr inbounds (%struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 1), align 2<br>
> + %1 = load i16* getelementptr inbounds (%struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 2), align 2<br>
> + %cmp = icmp sgt i16 %0, %1<br>
> + br i1 %cmp, label %if.then, label %if.else<br>
> +<br>
> +if.then: ; preds = %entry<br>
> + store i16 %0, i16* getelementptr inbounds (%struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 0), align 2<br>
> + br label %if.end8<br>
> +<br>
> +if.else: ; preds = %entry<br>
> + %cmp5 = icmp slt i16 %0, %1<br>
> + br i1 %cmp5, label %if.then7, label %if.end8<br>
> +<br>
> +if.then7: ; preds = %if.else<br>
> + store i16 %1, i16* getelementptr inbounds (%struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 0), align 2<br>
> + br label %if.end8<br>
> +<br>
> +if.end8: ; preds = %if.else, %if.then7, %if.then<br>
> + ret void<br>
> +}<br>
> +<br>
> +define void @test_i16_2cmp_unsigned_1() {<br>
> +; CHECK-LABEL: test_i16_2cmp_unsigned_1<br>
> +; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}<br>
> +; CHECK-NEXT: b.hi<br>
> +; CHECK-NOT: cmp<br>
> +; CHECK: <a href="http://b.ne" target="_blank">b.ne</a><br>
> +entry:<br>
> + %0 = load i16* getelementptr inbounds (%struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 1), align 2<br>
> + %1 = load i16* getelementptr inbounds (%struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 2), align 2<br>
> + %cmp = icmp ugt i16 %0, %1<br>
> + br i1 %cmp, label %if.then, label %if.else<br>
> +<br>
> +if.then: ; preds = %entry<br>
> + store i16 %0, i16* getelementptr inbounds (%struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 0), align 2<br>
> + br label %if.end8<br>
> +<br>
> +if.else: ; preds = %entry<br>
> + %cmp5 = icmp eq i16 %0, %1<br>
> + br i1 %cmp5, label %if.then7, label %if.end8<br>
> +<br>
> +if.then7: ; preds = %if.else<br>
> + store i16 %0, i16* getelementptr inbounds (%struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 0), align 2<br>
> + br label %if.end8<br>
> +<br>
> +if.end8: ; preds = %if.else, %if.then7, %if.then<br>
> + ret void<br>
> +}<br>
> +<br>
> +define void @test_i16_2cmp_unsigned_2() {<br>
> +; CHECK-LABEL: test_i16_2cmp_unsigned_2<br>
> +; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}<br>
> +; CHECK-NEXT: <a href="http://b.ls" target="_blank">b.ls</a><br>
> +; CHECK-NOT: cmp<br>
> +; CHECK: b.hs<br>
> +entry:<br>
> + %0 = load i16* getelementptr inbounds (%struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 1), align 2<br>
> + %1 = load i16* getelementptr inbounds (%struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 2), align 2<br>
> + %cmp = icmp ugt i16 %0, %1<br>
> + br i1 %cmp, label %if.then, label %if.else<br>
> +<br>
> +if.then: ; preds = %entry<br>
> + store i16 %0, i16* getelementptr inbounds (%struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 0), align 2<br>
> + br label %if.end8<br>
> +<br>
> +if.else: ; preds = %entry<br>
> + %cmp5 = icmp ult i16 %0, %1<br>
> + br i1 %cmp5, label %if.then7, label %if.end8<br>
> +<br>
> +if.then7: ; preds = %if.else<br>
> + store i16 %1, i16* getelementptr inbounds (%struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 0), align 2<br>
> + br label %if.end8<br>
> +<br>
> +if.end8: ; preds = %if.else, %if.then7, %if.then<br>
> + ret void<br>
> +}<br>
> +<br>
> +; The following cases are for i8<br>
> +<br>
> +%struct.s_signed_i8 = type { i8, i8, i8 }<br>
> +%struct.s_unsigned_i8 = type { i8, i8, i8 }<br>
> +<br>
> +@cost_s = common global %struct.s_signed_i8 zeroinitializer, align 2<br>
> +@cost_u_i8 = common global %struct.s_unsigned_i8 zeroinitializer, align 2<br>
> +<br>
> +<br>
> +define void @test_i8_2cmp_signed_1() {<br>
> +; CHECK-LABEL: test_i8_2cmp_signed_1<br>
> +; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}<br>
> +; CHECK-NEXT: <a href="http://b.gt" target="_blank">b.gt</a><br>
> +; CHECK-NOT: cmp<br>
> +; CHECK: <a href="http://b.ne" target="_blank">b.ne</a><br>
> +entry:<br>
> + %0 = load i8* getelementptr inbounds (%struct.s_signed_i8* @cost_s, i64 0, i32 1), align 2<br>
> + %1 = load i8* getelementptr inbounds (%struct.s_signed_i8* @cost_s, i64 0, i32 2), align 2<br>
> + %cmp = icmp sgt i8 %0, %1<br>
> + br i1 %cmp, label %if.then, label %if.else<br>
> +<br>
> +if.then: ; preds = %entry<br>
> + store i8 %0, i8* getelementptr inbounds (%struct.s_signed_i8* @cost_s, i64 0, i32 0), align 2<br>
> + br label %if.end8<br>
> +<br>
> +if.else: ; preds = %entry<br>
> + %cmp5 = icmp eq i8 %0, %1<br>
> + br i1 %cmp5, label %if.then7, label %if.end8<br>
> +<br>
> +if.then7: ; preds = %if.else<br>
> + store i8 %0, i8* getelementptr inbounds (%struct.s_signed_i8* @cost_s, i64 0, i32 0), align 2<br>
> + br label %if.end8<br>
> +<br>
> +if.end8: ; preds = %if.else, %if.then7, %if.then<br>
> + ret void<br>
> +}<br>
> +<br>
> +define void @test_i8_2cmp_signed_2() {<br>
> +; CHECK-LABEL: test_i8_2cmp_signed_2<br>
> +; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}<br>
> +; CHECK-NEXT: b.le<br>
> +; CHECK-NOT: cmp<br>
> +; CHECK: <a href="http://b.ge" target="_blank">b.ge</a><br>
> +entry:<br>
> + %0 = load i8* getelementptr inbounds (%struct.s_signed_i8* @cost_s, i64 0, i32 1), align 2<br>
> + %1 = load i8* getelementptr inbounds (%struct.s_signed_i8* @cost_s, i64 0, i32 2), align 2<br>
> + %cmp = icmp sgt i8 %0, %1<br>
> + br i1 %cmp, label %if.then, label %if.else<br>
> +<br>
> +if.then: ; preds = %entry<br>
> + store i8 %0, i8* getelementptr inbounds (%struct.s_signed_i8* @cost_s, i64 0, i32 0), align 2<br>
> + br label %if.end8<br>
> +<br>
> +if.else: ; preds = %entry<br>
> + %cmp5 = icmp slt i8 %0, %1<br>
> + br i1 %cmp5, label %if.then7, label %if.end8<br>
> +<br>
> +if.then7: ; preds = %if.else<br>
> + store i8 %1, i8* getelementptr inbounds (%struct.s_signed_i8* @cost_s, i64 0, i32 0), align 2<br>
> + br label %if.end8<br>
> +<br>
> +if.end8: ; preds = %if.else, %if.then7, %if.then<br>
> + ret void<br>
> +}<br>
> +<br>
> +define void @test_i8_2cmp_unsigned_1() {<br>
> +; CHECK-LABEL: test_i8_2cmp_unsigned_1<br>
> +; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}<br>
> +; CHECK-NEXT: b.hi<br>
> +; CHECK-NOT: cmp<br>
> +; CHECK: <a href="http://b.ne" target="_blank">b.ne</a><br>
> +entry:<br>
> + %0 = load i8* getelementptr inbounds (%struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 1), align 2<br>
> + %1 = load i8* getelementptr inbounds (%struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 2), align 2<br>
> + %cmp = icmp ugt i8 %0, %1<br>
> + br i1 %cmp, label %if.then, label %if.else<br>
> +<br>
> +if.then: ; preds = %entry<br>
> + store i8 %0, i8* getelementptr inbounds (%struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 0), align 2<br>
> + br label %if.end8<br>
> +<br>
> +if.else: ; preds = %entry<br>
> + %cmp5 = icmp eq i8 %0, %1<br>
> + br i1 %cmp5, label %if.then7, label %if.end8<br>
> +<br>
> +if.then7: ; preds = %if.else<br>
> + store i8 %0, i8* getelementptr inbounds (%struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 0), align 2<br>
> + br label %if.end8<br>
> +<br>
> +if.end8: ; preds = %if.else, %if.then7, %if.then<br>
> + ret void<br>
> +}<br>
> +<br>
> +define void @test_i8_2cmp_unsigned_2() {<br>
> +; CHECK-LABEL: test_i8_2cmp_unsigned_2<br>
> +; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}<br>
> +; CHECK-NEXT: <a href="http://b.ls" target="_blank">b.ls</a><br>
> +; CHECK-NOT: cmp<br>
> +; CHECK: b.hs<br>
> +entry:<br>
> + %0 = load i8* getelementptr inbounds (%struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 1), align 2<br>
> + %1 = load i8* getelementptr inbounds (%struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 2), align 2<br>
> + %cmp = icmp ugt i8 %0, %1<br>
> + br i1 %cmp, label %if.then, label %if.else<br>
> +<br>
> +if.then: ; preds = %entry<br>
> + store i8 %0, i8* getelementptr inbounds (%struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 0), align 2<br>
> + br label %if.end8<br>
> +<br>
> +if.else: ; preds = %entry<br>
> + %cmp5 = icmp ult i8 %0, %1<br>
> + br i1 %cmp5, label %if.then7, label %if.end8<br>
> +<br>
> +if.then7: ; preds = %if.else<br>
> + store i8 %1, i8* getelementptr inbounds (%struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 0), align 2<br>
> + br label %if.end8<br>
> +<br>
> +if.end8: ; preds = %if.else, %if.then7, %if.then<br>
> + ret void<br>
> +}<br>
> +<br>
> +; Make sure the case below won't crash.<br>
> +<br>
> +; The optimization of ZERO_EXTEND and SIGN_EXTEND in type legalization stage can't assert<br>
> +; the operand of a set_cc is always a TRUNCATE.<br>
> +<br>
> +define i1 @foo(float %inl, float %inr) {<br>
> + %lval = fptosi float %inl to i8<br>
> + %rval = fptosi float %inr to i8<br>
> + %sum = icmp eq i8 %lval, %rval<br>
> + ret i1 %sum<br>
> +}<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>