Files
clang-p2996/llvm/test/Transforms/ConstantHoisting/ARM/apint-assert.ll
Nikita Popov 8851ea64a5 [ConstantHoist] Fix APInt ctor assertion
The result here may require truncation. Fix this by removing the
calculateOffsetDiff() helper entirely. As far as I can tell, this
code does not actually have to deal with different bitwidths.

findBaseConstants() will produce ranges of constants with equal
types, which is what maximizeConstantsInRange() will then work
on.

Fixes assertion reported at:
https://github.com/llvm/llvm-project/pull/114539#issuecomment-2453008679
2024-11-04 11:17:24 +01:00

19 lines
735 B
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -S -passes=consthoist -mtriple=armv4t-unknown-linux-gnueabi < %s | FileCheck %s
define i1 @test(i32 %arg) optsize {
; CHECK-LABEL: define i1 @test(
; CHECK-SAME: i32 [[ARG:%.*]]) #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[CONST:%.*]] = bitcast i32 380633088 to i32
; CHECK-NEXT: [[CONST_MAT:%.*]] = add i32 [[CONST]], -381681664
; CHECK-NEXT: [[SHR_MASK:%.*]] = and i32 [[ARG]], [[CONST_MAT]]
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[SHR_MASK]], [[CONST]]
; CHECK-NEXT: ret i1 [[CMP]]
;
entry:
%shr.mask = and i32 %arg, -1048576
%cmp = icmp eq i32 %shr.mask, 380633088
ret i1 %cmp
}