Skip to content

Commit b4cf714

Browse files
vladimirradosavljevicakiramenai
authored andcommitted
[EVM] Add pre-commit test for Fold signextend(b, signextend(b, x)) -> signextend(b, x)
Signed-off-by: Vladimir Radosavljevic <[email protected]>
1 parent a9e468e commit b4cf714

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -passes=instcombine -S < %s | FileCheck %s
3+
4+
target datalayout = "E-p:256:256-i256:256:256-S256-a:256:256"
5+
target triple = "evm"
6+
7+
define i256 @test_const(i256 %x) {
8+
; CHECK-LABEL: define i256 @test_const(
9+
; CHECK-SAME: i256 [[X:%.*]]) {
10+
; CHECK-NEXT: [[SIGNEXT1:%.*]] = call i256 @llvm.evm.signextend(i256 15, i256 [[X]])
11+
; CHECK-NEXT: [[SIGNEXT2:%.*]] = call i256 @llvm.evm.signextend(i256 15, i256 [[SIGNEXT1]])
12+
; CHECK-NEXT: ret i256 [[SIGNEXT2]]
13+
;
14+
%signext1 = call i256 @llvm.evm.signextend(i256 15, i256 %x)
15+
%signext2 = call i256 @llvm.evm.signextend(i256 15, i256 %signext1)
16+
ret i256 %signext2
17+
}
18+
19+
define i256 @test_const_ne(i256 %x) {
20+
; CHECK-LABEL: define i256 @test_const_ne(
21+
; CHECK-SAME: i256 [[X:%.*]]) {
22+
; CHECK-NEXT: [[SIGNEXT1:%.*]] = call i256 @llvm.evm.signextend(i256 15, i256 [[X]])
23+
; CHECK-NEXT: [[SIGNEXT2:%.*]] = call i256 @llvm.evm.signextend(i256 10, i256 [[SIGNEXT1]])
24+
; CHECK-NEXT: ret i256 [[SIGNEXT2]]
25+
;
26+
%signext1 = call i256 @llvm.evm.signextend(i256 15, i256 %x)
27+
%signext2 = call i256 @llvm.evm.signextend(i256 10, i256 %signext1)
28+
ret i256 %signext2
29+
}
30+
31+
define i256 @test_var(i256 %b, i256 %x) {
32+
; CHECK-LABEL: define i256 @test_var(
33+
; CHECK-SAME: i256 [[B:%.*]], i256 [[X:%.*]]) {
34+
; CHECK-NEXT: [[SIGNEXT1:%.*]] = call i256 @llvm.evm.signextend(i256 [[B]], i256 [[X]])
35+
; CHECK-NEXT: [[SIGNEXT2:%.*]] = call i256 @llvm.evm.signextend(i256 [[B]], i256 [[SIGNEXT1]])
36+
; CHECK-NEXT: ret i256 [[SIGNEXT2]]
37+
;
38+
%signext1 = call i256 @llvm.evm.signextend(i256 %b, i256 %x)
39+
%signext2 = call i256 @llvm.evm.signextend(i256 %b, i256 %signext1)
40+
ret i256 %signext2
41+
}
42+
43+
define i256 @test_var_ne(i256 %b1, i256 %b2, i256 %x) {
44+
; CHECK-LABEL: define i256 @test_var_ne(
45+
; CHECK-SAME: i256 [[B1:%.*]], i256 [[B2:%.*]], i256 [[X:%.*]]) {
46+
; CHECK-NEXT: [[SIGNEXT1:%.*]] = call i256 @llvm.evm.signextend(i256 [[B1]], i256 [[X]])
47+
; CHECK-NEXT: [[SIGNEXT2:%.*]] = call i256 @llvm.evm.signextend(i256 [[B2]], i256 [[SIGNEXT1]])
48+
; CHECK-NEXT: ret i256 [[SIGNEXT2]]
49+
;
50+
%signext1 = call i256 @llvm.evm.signextend(i256 %b1, i256 %x)
51+
%signext2 = call i256 @llvm.evm.signextend(i256 %b2, i256 %signext1)
52+
ret i256 %signext2
53+
}
54+
55+
declare i256 @llvm.evm.signextend(i256, i256)

0 commit comments

Comments
 (0)