mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Allow min/max detection to see through casts.
This teaches the min/max idiom detector in ValueTracking to see through casts such as SExt/ZExt/Trunc. SCEV can already do this, so we're bringing non-SCEV analyses up to the same level. The returned LHS/RHS will not match the type of the original SelectInst any more, so a CastOp is returned too to inform the caller how to convert to the SelectInst's type. No in-tree users yet; this will be used by InstCombine in a followup. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237452 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#define LLVM_ANALYSIS_VALUETRACKING_H
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/IR/Instruction.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
|
||||
namespace llvm {
|
||||
@@ -280,7 +281,21 @@ namespace llvm {
|
||||
};
|
||||
/// Pattern match integer [SU]MIN, [SU]MAX and ABS idioms, returning the kind
|
||||
/// and providing the out parameter results if we successfully match.
|
||||
SelectPatternFlavor matchSelectPattern(Value *V, Value *&LHS, Value *&RHS);
|
||||
///
|
||||
/// If CastOp is not nullptr, also match MIN/MAX idioms where the type does
|
||||
/// not match that of the original select. If this is the case, the cast
|
||||
/// operation (one of Trunc,SExt,Zext) that must be done to transform the
|
||||
/// type of LHS and RHS into the type of V is returned in CastOp.
|
||||
///
|
||||
/// For example:
|
||||
/// %1 = icmp slt i32 %a, i32 4
|
||||
/// %2 = sext i32 %a to i64
|
||||
/// %3 = select i1 %1, i64 %2, i64 4
|
||||
///
|
||||
/// -> LHS = %a, RHS = i32 4, *CastOp = Instruction::SExt
|
||||
///
|
||||
SelectPatternFlavor matchSelectPattern(Value *V, Value *&LHS, Value *&RHS,
|
||||
Instruction::CastOps *CastOp = nullptr);
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
|
Reference in New Issue
Block a user