mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 00:24:26 +00:00
Teach the constant folder how to not a cmpinst.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82378 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -704,6 +704,20 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||||||
break;
|
break;
|
||||||
case Instruction::Xor:
|
case Instruction::Xor:
|
||||||
if (CI2->equalsInt(0)) return C1; // X ^ 0 == X
|
if (CI2->equalsInt(0)) return C1; // X ^ 0 == X
|
||||||
|
|
||||||
|
if (ConstantExpr *CE1 = dyn_cast<ConstantExpr>(C1)) {
|
||||||
|
switch (CE1->getOpcode()) {
|
||||||
|
default: break;
|
||||||
|
case Instruction::ICmp:
|
||||||
|
case Instruction::FCmp:
|
||||||
|
// icmp pred ^ true -> icmp !pred
|
||||||
|
assert(CI2->equalsInt(1));
|
||||||
|
CmpInst::Predicate pred = (CmpInst::Predicate)CE1->getPredicate();
|
||||||
|
pred = CmpInst::getInversePredicate(pred);
|
||||||
|
return ConstantExpr::getCompare(pred, CE1->getOperand(0),
|
||||||
|
CE1->getOperand(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Instruction::AShr:
|
case Instruction::AShr:
|
||||||
// ashr (zext C to Ty), C2 -> lshr (zext C, CSA), C2
|
// ashr (zext C to Ty), C2 -> lshr (zext C, CSA), C2
|
||||||
|
@ -28,3 +28,9 @@ global i1 icmp ule (i32* bitcast (i8* @X to i32*), i32* bitcast (i8* @Y to i32*)
|
|||||||
; CHECK-NOT: bitcast
|
; CHECK-NOT: bitcast
|
||||||
; CHECK: icmp
|
; CHECK: icmp
|
||||||
|
|
||||||
|
global i1 icmp eq (i1 icmp ult (i8* @X, i8* @Y), i1 false)
|
||||||
|
; CHECK-NOT: false
|
||||||
|
; CHECK: icmp
|
||||||
|
global i1 icmp eq (i1 icmp ult (i8* @X, i8* @Y), i1 true)
|
||||||
|
; CHECK-NOT: true
|
||||||
|
; CHECK: icmp
|
||||||
|
Reference in New Issue
Block a user