mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-31 10:34:17 +00:00
InstCombine: Fix a combine assuming that icmp operands were integers
An icmp may have pointer arguments, it isn't limited to integers or vectors of integers. This fixes PR21388. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220664 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e250b13ab9
commit
fe58be3733
@ -900,6 +900,10 @@ Instruction *InstCombiner::transformSExtICmp(ICmpInst *ICI, Instruction &CI) {
|
||||
Value *Op0 = ICI->getOperand(0), *Op1 = ICI->getOperand(1);
|
||||
ICmpInst::Predicate Pred = ICI->getPredicate();
|
||||
|
||||
// Don't bother if Op1 isn't of vector or integer type.
|
||||
if (!Op1->getType()->isIntOrIntVectorTy())
|
||||
return nullptr;
|
||||
|
||||
if (Constant *Op1C = dyn_cast<Constant>(Op1)) {
|
||||
// (x <s 0) ? -1 : 0 -> ashr x, 31 -> all ones if negative
|
||||
// (x >s -1) ? -1 : 0 -> not (ashr x, 31) -> all ones if positive
|
||||
|
@ -1084,3 +1084,12 @@ define float @overflow_sitofp() {
|
||||
; CHECK-NEXT: ret float undef
|
||||
}
|
||||
|
||||
define i32 @PR21388(i32* %v) {
|
||||
%icmp = icmp slt i32* %v, null
|
||||
%sext = sext i1 %icmp to i32
|
||||
ret i32 %sext
|
||||
; CHECK-LABEL: @PR21388(
|
||||
; CHECK-NEXT: %[[icmp:.*]] = icmp slt i32* %v, null
|
||||
; CHECK-NEXT: %[[sext:.*]] = sext i1 %[[icmp]] to i32
|
||||
; CHECK-NEXT: ret i32 %[[sext]]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user