-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed
Labels
llvm:SelectionDAGSelectionDAGISel as wellSelectionDAGISel as wellquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Description
๐ก Example: Trunc + Zext in LLVM IR
The following function demonstrates a trunc followed by a zext:
define i64 @bar(i64 %a) {
; CHECK-LABEL: bar:
; CHECK: ; %bb.0:
; CHECK-NEXT: ret 0
%trunc = trunc nuw nsw i64 %a to i32
%res = zext i32 %trunc to i64
ret i64 %res
}Ideally, LLVM should emit code that preserves the lower 32 bits of %a and zeros out the upper 32 bits. However, in the latest LLVM, it appears this truncation + zero-extension is incorrectly optimized into a constant 0. Since it's a new feature, I am not sure what's the correct semantics of nuw/nsw in trunc instruction.
This behavior is likely a regression and may be closely related to the following patch:
๐ #113808
Metadata
Metadata
Assignees
Labels
llvm:SelectionDAGSelectionDAGISel as wellSelectionDAGISel as wellquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!