LLVM 23.0.0git
OverflowInstAnalysis.h
Go to the documentation of this file.
1//===-- OverflowInstAnalysis.h - Utils to fold overflow insts ----*- C++ -*-==//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file holds routines to help analyse overflow instructions
10// and fold them into constants or other overflow instructions
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_ANALYSIS_OVERFLOWINSTANALYSIS_H
15#define LLVM_ANALYSIS_OVERFLOWINSTANALYSIS_H
16
18
19namespace llvm {
20class Use;
21class Value;
22
23/// Match one of the patterns up to the select/logic op:
24/// %Op0 = icmp ne i4 %X, 0
25/// %Agg = call { i4, i1 } @llvm.[us]mul.with.overflow.i4(i4 %X, i4 %Y)
26/// %Op1 = extractvalue { i4, i1 } %Agg, 1
27/// %ret = select i1 %Op0, i1 %Op1, i1 false / %ret = and i1 %Op0, %Op1
28///
29/// %Op0 = icmp eq i4 %X, 0
30/// %Agg = call { i4, i1 } @llvm.[us]mul.with.overflow.i4(i4 %X, i4 %Y)
31/// %NotOp1 = extractvalue { i4, i1 } %Agg, 1
32/// %Op1 = xor i1 %NotOp1, true
33/// %ret = select i1 %Op0, i1 true, i1 %Op1 / %ret = or i1 %Op0, %Op1
34///
35/// Callers are expected to align that with the operands of the select/logic.
36/// IsAnd is set to true if the Op0 and Op1 are used as the first pattern.
37/// If Op0 and Op1 match one of the patterns above, return true and fill Y's
38/// use.
39
41 bool IsAnd, Use *&Y);
43 bool IsAnd);
44} // end namespace llvm
45
46#endif
#define LLVM_ABI
Definition Compiler.h:213
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
LLVM Value Representation.
Definition Value.h:75
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool isCheckForZeroAndMulWithOverflow(Value *Op0, Value *Op1, bool IsAnd, Use *&Y)
Match one of the patterns up to the select/logic op: Op0 = icmp ne i4 X, 0 Agg = call { i4,...