mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 20:09:46 +00:00
[InstCombine] Fold abs intrinsic eq zero
Following the same transform for the select version of abs.
This commit is contained in:
parent
0df23d0dc6
commit
ecd979f4bb
@ -3088,6 +3088,13 @@ Instruction *InstCombinerImpl::foldICmpEqIntrinsicWithConstant(
|
||||
Type *Ty = II->getType();
|
||||
unsigned BitWidth = C.getBitWidth();
|
||||
switch (II->getIntrinsicID()) {
|
||||
case Intrinsic::abs:
|
||||
// abs(A) == 0 -> A == 0
|
||||
if (C.isNullValue())
|
||||
return new ICmpInst(Cmp.getPredicate(), II->getArgOperand(0),
|
||||
Constant::getNullValue(Ty));
|
||||
break;
|
||||
|
||||
case Intrinsic::bswap:
|
||||
// bswap(A) == C -> A == bswap(C)
|
||||
return new ICmpInst(Cmp.getPredicate(), II->getArgOperand(0),
|
||||
|
@ -1094,8 +1094,7 @@ define zeroext i1 @cmpabs2(i64 %val) {
|
||||
|
||||
define i1 @abs_intrin_eq_zero(i8 %x) {
|
||||
; CHECK-LABEL: @abs_intrin_eq_zero(
|
||||
; CHECK-NEXT: [[ABS:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 false)
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[ABS]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[X:%.*]], 0
|
||||
; CHECK-NEXT: ret i1 [[CMP]]
|
||||
;
|
||||
%abs = call i8 @llvm.abs.i8(i8 %x, i1 false)
|
||||
@ -1105,8 +1104,7 @@ define i1 @abs_intrin_eq_zero(i8 %x) {
|
||||
|
||||
define i1 @abs_intrin_ne_zero(i8 %x) {
|
||||
; CHECK-LABEL: @abs_intrin_ne_zero(
|
||||
; CHECK-NEXT: [[ABS:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 false)
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 [[ABS]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 [[X:%.*]], 0
|
||||
; CHECK-NEXT: ret i1 [[CMP]]
|
||||
;
|
||||
%abs = call i8 @llvm.abs.i8(i8 %x, i1 false)
|
||||
|
Loading…
Reference in New Issue
Block a user