forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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: llvm#114539 (comment)
- Loading branch information
Showing
2 changed files
with
25 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
; 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 | ||
} |