Skip to content

[SLPVectorizer] Wrong value truncation  #104422

Closed
@aleks-tmb

Description

@aleks-tmb
  • There seems to be an issue with SLPVectorizer. In the following example, a 2-byte wide value is incorrectly truncated:
define i64 @test(ptr addrspace(1) %arr, i32 %a) {
entry:
  br label %loop

loop:
  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
  %local_1_7 = phi i64 [ 0, %entry ], [ %4, %loop ]
  %0 = sext i32 %a to i64
  %1 = add nsw i64 %0, 4294967297
  %2 = add i64 %1, %local_1_7
  %3 = and i64 %1, 1
  %4 = add i64 %2, %3
  %iv.next = add nuw nsw i64 %iv, 1
  %5 = icmp ugt i64 %iv, 355
  br i1 %5, label %exit, label %loop

exit:
  ret i64 %4
}
  • In the loop we summarize the constant 4294967297 (0x1'0000'0001), but after running SLPVectorizer over the unrolled loop, the constant is truncated to 1:
loop: 
  %iv = phi i64 [ 0, %entry ], [ %iv.next.16, %loop ]
  %local_1_7 = phi i64 [ 0, %entry ], [ %op.rdx3, %loop ]
  %2 = add <16 x i32> %1, <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>
  %3 = sext <16 x i32> %2 to <16 x i64>
...

@alexey-bataev Could you please take a look?

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions