search for: m_valu

Displaying 20 results from an estimated 31 matches for "m_valu".

Did you mean: m_value
2017 Jul 13
2
failing to optimize boolean ops on cmps
...s case without adding a new matcher. Eg: >> >> > I would rather see this added to instsimplify than instcombine. > If you do that, GVN/et all will get this already. > > This probably does require a special matcher though: > > > We have: > if (m_c_And(m_Cmp(Pred, m_Value(), m_Value()), > m_Cmp(Pred, m_Value(), m_Value())) > > and you really want: > if (m_c_And(m_Cmp(Pred, m_Value(), m_Value()), > m_Cmp(m_Opposite(Pred), m_Value(), m_Value())) > > > > -------------- next part -------------- An HTML attachment...
2017 Jul 13
2
failing to optimize boolean ops on cmps
...ding to the existing InstCombine logic folds to handle this kind of pattern be a welcome enhancement? I don't know if it's possible to make the matchers handle this case without adding a new matcher. Eg: // ((~A & B) | A) -> (A | B) if (match(Op0, m_c_And(m_Not(m_Specific(Op1)), m_Value(A)))) return BinaryOperator::CreateOr(A, Op1); Is there a way to make "m_Not(m_Specific())" match an inverted compare? This optimization hole can manifest in strange ways: https://godbolt.org/g/gjpAVo We got it right for C++, but C managed to fall through the cracks! -------------...
2018 Dec 18
2
should we do this time-consuming transform in InstCombine?
...wed. This should match that *specific* pattern (other than verifying the correct equal binop types), although i have not tested it: ICmpInst::Predicate Pred; Value *A, *B, *Mul, *Sub, *Mul2; if (match(&SI, m_Select(m_ICmp(Pred, m_CombineAnd(m_BinOp(m_Value(A), m_Value(B)), m_Value(Mul)), m_AllOnes()), m_Deferred(Mul), m_CombineAnd( m_c_BinOp(m_CombineAnd(m_Sub(m_Zero(), m_Deferred (A)),...
2018 Dec 18
2
should we do this time-consuming transform in InstCombine?
Hi, There is an opportunity in instCombine for following instruction pattern: %mul = mul nsw i32 %b, %a %cmp = icmp sgt i32 %mul, -1 %sub = sub i32 0, %a %mul2 = mul nsw i32 %sub, %b %cond = select i1 %cmp, i32 %mul, i32 %mul2 Source code for above pattern: return (a*b) >=0 ? (a*b) : -a*b; Currently, llvm(-O3) can not recognize this as abs(a*b). I initially think we could do this in
2008 May 17
0
[LLVMdev] More info, was Help needed after hiatus
...preds = %entry > ret void > } BTW, It's usually better to file a bug for this sort of thing. The issue is around InstructionCombining:2507: // W*X + Y*Z --> W * (X+Z) iff W == Y if (I.getType()->isIntOrIntVector()) { Value *W, *X, *Y, *Z; if (match(LHS, m_Mul(m_Value(W), m_Value(X))) && match(RHS, m_Mul(m_Value(Y), m_Value(Z)))) { The issue starts with the lines: add i32 %2, 2 ; <i32>:3 [#uses=1] mul i32 %3, ptrtoint (i32* getelementptr (i32* null, i32 1) to i32) ; <i32>:4 [#uses=1] Roughly, t...
2008 May 17
2
[LLVMdev] More info, was Help needed after hiatus
Hi, I know my last question was very vague (i.e. "It stopped working, what went wrong?"), so here is a little more concrete example: If I run the optimizer (opt) on this code snippet with -std-compile-opts the optimizer hangs. ; ModuleID = 'test.ubc' target datalayout =
2019 Dec 31
3
Any significance for m_OneUse in (X / Y) / Z => X / (Y * Z) ??
Dear All, The InstCombine pass performs the following transformation. Z / (X / Y) => (Y * Z) / X This is performed only when operand Op1 ( (X/Y) in this case) has only one use in future. The code snippet is shown below. if (match(Op1, m_OneUse(m_FDiv(m_Value(X), m_Value(Y)))) && (!isa<Constant>(Y) || !isa<Constant>(Op0))) { // Z / (X / Y) => (Y * Z) / X Value *YZ = Builder.CreateFMulFMF(Y, Op0, &I); return BinaryOperator::CreateFDivFMF(YZ, X, &I); } It would be great if someone explains if...
2017 Jul 14
2
failing to optimize boolean ops on cmps
...her. Eg: > > > I would rather see this added to instsimplify than instcombine. > If you do that, GVN/et all will get this already. > > This probably does require a special matcher though: > > > We have: > if (m_c_And(m_Cmp(Pred, m_Value(), m_Value()), > m_Cmp(Pred, m_Value(), m_Value())) > > and you really want: > if (m_c_And(m_Cmp(Pred, m_Value(), m_Value()), > m_Cmp(m_Opposite(Pred), m_Value(), m_Value())) > > > > > > > > _____________________...
2008 Nov 09
2
[LLVMdev] m_Not Pattern Question
I have a question about the pattern matching stuff that's used in the Instruction Combiner. If I have code like this: if (match(B, m_Select(m_Value(), m_ConstantInt(0), m_ConstantInt(-1)))) { if (match(C, m_Not(m_Value(B)))) return SelectInst::Create(cast<User>(B)->getOperand(0), D, A); and we match, the program fails during the "SelectInst::Create" phase. The problem is because B is now a Constant with...
2010 Jan 05
0
[LLVMdev] [llvm-commits] [llvm] r92458 - in /llvm/trunk: lib/Target/README.txt lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/or.ll
...t; - V1 = 0; V2 = 0; V3 = 0; >> + >> + // ((V | N) & C1) | (V & C2) --> (V|N) & (C1|C2) >> + // iff (C1&C2) == 0 and (N&~C1) == 0 >> + if ((C1->getValue() & C2->getValue()) == 0) { >> + if (match(A, m_Or(m_Value(V1), m_Value(V2))) && >> + ((V1 == B && MaskedValueIsZero(V2, ~C1->getValue())) || // (V|N) >> + (V2 == B && MaskedValueIsZero(V1, ~C1->getValue())))) // (N|V) >> + return BinaryOperator::CreateAnd(A, >> +...
2020 Jan 03
3
Any significance for m_OneUse in (X / Y) / Z => X / (Y * Z) ??
...e pass performs the following transformation. >> >> Z / (X / Y) => (Y * Z) / X >> >> This is performed only when operand Op1 ( (X/Y) in this case) has only >> one use in future. The code snippet is shown below. >> >> if (match(Op1, m_OneUse(m_FDiv(m_Value(X), m_Value(Y)))) && >> (!isa<Constant>(Y) || !isa<Constant>(Op0))) { >> // Z / (X / Y) => (Y * Z) / X >> Value *YZ = Builder.CreateFMulFMF(Y, Op0, &I); >> return BinaryOperator::CreateFDivFMF(YZ, X, &I); >>...
2012 Oct 30
0
[LLVMdev] Any plan to add MIN/MAX isd node?
...ect and Compare is not associative > neither. at the IR level LLVM already has pattern matching helpers for identifying min/max idioms, here is part of a transform using this, from InstructionSimplify.cpp: // Signed variants on "max(a,b)>=a -> true". if (match(LHS, m_SMax(m_Value(A), m_Value(B))) && (A == RHS || B == RHS)) { if (A != RHS) std::swap(A, B); // smax(A, B) pred A. EqP = CmpInst::ICMP_SGE; // "A == smax(A, B)" iff "A sge B". // We analyze this as smax(A, B) pred A. P = Pred; } At the codegen level, the same co...
2012 Oct 30
1
[LLVMdev] Any plan to add MIN/MAX isd node?
.... Select and Compare is not associative neither. at the IR level LLVM already has pattern matching helpers for identifying min/max idioms, here is part of a transform using this, from InstructionSimplify.cpp: // Signed variants on "max(a,b)>=a -> true". if (match(LHS, m_SMax(m_Value(A), m_Value(B))) && (A == RHS || B == RHS)) { if (A != RHS) std::swap(A, B); // smax(A, B) pred A. EqP = CmpInst::ICMP_SGE; // "A == smax(A, B)" iff "A sge B". // We analyze this as smax(A, B) pred A. P = Pred; } At the codegen level, the same co...
2012 Oct 30
2
[LLVMdev] Any plan to add MIN/MAX isd node?
Hi Duncan, To use select, usually, there is a compare before select. Presence of comparison will disable some opportunities to optimize some code. Select and Compare is not associative neither. Thanks, Yin -----Original Message----- From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Duncan Sands Sent: Tuesday, October 30, 2012
2020 Jan 06
2
Any significance for m_OneUse in (X / Y) / Z => X / (Y * Z) ??
...t;> >>>> Z / (X / Y) => (Y * Z) / X >>>> >>>> This is performed only when operand Op1 ( (X/Y) in this case) has only >>>> one use in future. The code snippet is shown below. >>>> >>>> if (match(Op1, m_OneUse(m_FDiv(m_Value(X), m_Value(Y)))) && >>>> (!isa<Constant>(Y) || !isa<Constant>(Op0))) { >>>> // Z / (X / Y) => (Y * Z) / X >>>> Value *YZ = Builder.CreateFMulFMF(Y, Op0, &I); >>>> return BinaryOperator::CreateFDiv...
2015 Apr 15
2
[LLVMdev] Instruction combiner multiplication canonicalization
...roperty. Please confirm my understanding. <File: InstCombineMulDivRem.cpp > 168 Instruction *InstCombiner::visitMul(BinaryOperator &I) { 268 // Canonicalize (X+C1)*CI -> X*CI+C1*CI. 269 { 270 Value *X; 271 Constant *C1; 272 if (match(Op0, m_OneUse(m_Add(m_Value(X), m_Constant(C1))))) { 273 Value *Mul = Builder->CreateMul(C1, Op1); 274 // Only go forward with the transform if C1*CI simplifies to a tidier 275 // constant. 276 if (!match(Mul, m_Mul(m_Value(), m_Value()))) 277 return BinaryOperator::CreateAdd...
2020 Nov 16
1
Complex proposal v3 + roundtable agenda
...* > return SimplifyFAddInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse); > ``` > > And when a transformation succeeds, we'd need to update how the result > is returned. E.g.: > > ``` > // (-X) + Y --> Y - X > Value *X, *Y; > if (match(&I, m_c_FAdd(m_FNeg(m_Value(X)), m_Value(Y)))) > return BinaryOperator::CreateFSubFMF(Y, X, &I); <== ***HERE*** > ``` > > Both of those come for free with a complex type, along with the > pattern matching code. > > > Thanks for expanding on this! I think for InstructionSimplify it should be...
2014 Jul 01
2
[LLVMdev] Probable error in InstCombine
...t; } > > int main (void) > { > printf ("%d\n", foo(INT_MIN)); > } This will print -1 or 1, depending on the optimization level. This appears to be the relevant code: InstCombineAddSub.cpp:1556 > // 0 - (X sdiv C) -> (X sdiv -C) > if (match(Op1, m_SDiv(m_Value(X), m_Constant(C))) && > match(Op0, m_Zero())) > return BinaryOperator::CreateSDiv(X, ConstantExpr::getNeg(C)); - David Menendez
2014 May 19
2
Tripp Lite SMART3000RM2U (protocol 3003) running time and charge?
.../ (V_interval[1] - V_interval[0]))); + dstate_setinfo("battery.charge", "%3d", bp); + } + /* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */ ret = send_cmd(m_msg, sizeof(m_msg), m_value, sizeof(m_value)); ------ end patch ------ This is against NUT 2.7.1 and so will probably not apply cleanly on the current latest and greatest. I would not apply it as is anyway since it is quick and dirty and I am sure that it may be simplified (the conditional in particular is probably not nee...
2020 Nov 12
2
Complex proposal v3 + roundtable agenda
...; case Instruction::FAdd: <== ***HERE*** return SimplifyFAddInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse); ``` And when a transformation succeeds, we'd need to update how the result is returned. E.g.: ``` // (-X) + Y --> Y - X Value *X, *Y; if (match(&I, m_c_FAdd(m_FNeg(m_Value(X)), m_Value(Y)))) return BinaryOperator::CreateFSubFMF(Y, X, &I); <== ***HERE*** ``` Both of those come for free with a complex type, along with the pattern matching code. I'm not opposed to finding solutions for these problems, but this pitch has been around for a while now, and...