https://llvm.org/bugs/show_bug.cgi?id=31517
Bug ID: 31517 Summary: The LoadCombine pass wrongly reorder load and store Product: libraries Version: trunk Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: Scalar Optimizations Assignee: unassignedb...@nondot.org Reporter: karl-johan.karls...@ericsson.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified Created attachment 17800 --> https://llvm.org/bugs/attachment.cgi?id=17800&action=edit opt -S -load-combine -adce -o - loadcombine.ll | FileCheck loadcombine.ll Input code: define i16 @bazinga() { %_tmp9 = getelementptr %rec11, %rec11* @str, i16 0, i32 1 %_tmp10 = load i16, i16* %_tmp9 %_tmp12 = getelementptr %rec11, %rec11* @str, i16 0, i32 0 store i16 %_tmp10, i16* %_tmp12 %_tmp13 = getelementptr %rec11, %rec11* @str, i16 0, i32 0 %_tmp14 = load i16, i16* %_tmp13 %_tmp15 = icmp eq i16 %_tmp14, 3 %_tmp16 = select i1 %_tmp15, i16 1, i16 0 br label %bb1 bb1: ret i16 %_tmp16 } The load combiner can not reorder the three memory operations above (load, store, load) as the first load will load the value from the second location in the struct, the store will write the loaded value in the first location in the struct and the last load will load a value from the second location in the struct. Output code: define i16 @bazinga() { %_tmp14.combined = load i32, i32* bitcast (%rec11* @str to i32*) %combine.extract.shift = lshr i32 %_tmp14.combined, 16 %combine.extract.trunc1 = trunc i32 %combine.extract.shift to i16 %_tmp12 = getelementptr %rec11, %rec11* @str, i16 0, i32 0 store i16 %combine.extract.trunc1, i16* %_tmp12 %combine.extract.trunc = trunc i32 %_tmp14.combined to i16 %_tmp15 = icmp eq i16 %combine.extract.trunc, 3 %_tmp16 = select i1 %_tmp15, i16 1, i16 0 br label %bb1 bb1: ret i16 %_tmp16 } The load combine pass have combined the two loads and thereby reordered the instructions as the store is done afterwards. Result is that the input value to the icmp do not get the updated value written by the store. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs