File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
test/Transforms/FunctionAttrs Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,9 @@ bool Operator::hasPoisonGeneratingFlags() const {
28
28
return OBO->hasNoUnsignedWrap () || OBO->hasNoSignedWrap ();
29
29
}
30
30
case Instruction::Trunc: {
31
- auto *TI = dyn_cast<TruncInst>(this );
32
- return TI->hasNoUnsignedWrap () || TI->hasNoSignedWrap ();
31
+ if (auto *TI = dyn_cast<TruncInst>(this ))
32
+ return TI->hasNoUnsignedWrap () || TI->hasNoSignedWrap ();
33
+ return false ;
33
34
}
34
35
case Instruction::UDiv:
35
36
case Instruction::SDiv:
Original file line number Diff line number Diff line change 1
1
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2
2
; RUN: opt < %s -passes='function-attrs' -S | FileCheck %s
3
3
4
+ @g_var = external global [0 x i8 ]
5
+
4
6
define i32 @test_ret_constant () {
5
7
; CHECK-LABEL: define noundef i32 @test_ret_constant(
6
8
; CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
@@ -152,3 +154,15 @@ define i32 @test_ret_constant_msan() sanitize_memory {
152
154
;
153
155
ret i32 0
154
156
}
157
+
158
+ define i64 @test_trunc_with_constexpr () {
159
+ ; CHECK-LABEL: define noundef i64 @test_trunc_with_constexpr(
160
+ ; CHECK-SAME: ) #[[ATTR0]] {
161
+ ; CHECK-NEXT: [[ADD:%.*]] = add i32 trunc (i64 sub (i64 0, i64 ptrtoint (ptr @g_var to i64)) to i32), 1
162
+ ; CHECK-NEXT: [[CONV:%.*]] = sext i32 [[ADD]] to i64
163
+ ; CHECK-NEXT: ret i64 [[CONV]]
164
+ ;
165
+ %add = add i32 trunc (i64 sub (i64 0 , i64 ptrtoint (ptr @g_var to i64 )) to i32 ), 1
166
+ %conv = sext i32 %add to i64
167
+ ret i64 %conv
168
+ }
You can’t perform that action at this time.
0 commit comments